【问题标题】:Using rsync with ssh keygen使用 rsync 和 ssh keygen
【发布时间】:2020-03-18 14:20:37
【问题描述】:

我有一个 Debian 服务器,我想创建一个 cron 来将数据从我的服务器保存到连接到我的 mac 的远程硬盘驱动器。

所以,我做了这个正确运行的命令:

rsync -ah -progress -delete -e ssh xxxxxxx@1xx.1xx.1xx.1xx:/var/www/html/AccesBD/file /Volumes/USB-HDD

但我必须输入密码。

我使用 ssh-keygen 制作了文件 id_rsa_lb(不是 id_rsa),并用

发送了它
ssh-copy-id -i ~/.ssh/id_rsa_lb.pub 1xx.1xx.1xx.1xx

ssh -i ~/.ssh/id_rsa_lb lxxxxxxxxxx@1xx.1xx.1xx.1xx 命令运行正确,不需要任何密码。没关系。

但是当我尝试使用 ssh/id_rsa_lb 运行 rsync 时,出现错误:

rsync -ah -progress -delete -e ssh -i ~/.ssh/id_rsa_lb lxxxxxxxxx@1xx.1xx.1xx.1xx /var/opt/file /Volumes/USB-HDD

rsync: link_stat "/Users/yyyyy_yyyyy/.ssh/lxxxxxxxxx@1xx.1xx.1xx.1xx" failed: No such file or directory (2)
rsync: link_stat "/var/opt/base.sql" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54/rsync/main.c(996) [sender=2.6.9]

你能告诉我有什么问题吗?

谢谢

【问题讨论】:

    标签: ssh debian ssh-keygen


    【解决方案1】:

    使用引号,-e 只需要一个参数。

    rsync user@host:src_path local_dest_path ... -e "ssh -i ~/.ssh/id_rsa_lb" 
    

    【讨论】:

    • 我做了 rsync -ah -progress -delete -e "ssh -i ~/.ssh/id_rsa_lb" lxxxxxxxxx@1xx.1xx.1xx.1xx /var/opt/file /Volumes/USB-硬盘,但我有完全相同的错误
    • @MisterFisher 好的,您阅读 rsync 帮助了吗?您至少需要一个有效的源和一个目标,添加一个服务器和两个路径。因此,您会收到错误 ... failed: No such file or directory
    • 哦!抱歉...只是 lxxxxxxxxx@1xx.1xx.1xx.1xx 和 /var/opt/file 之间缺少“:”
    猜你喜欢
    • 2013-07-30
    • 2021-09-10
    • 2016-09-15
    • 2019-01-20
    • 2018-09-08
    • 2015-05-12
    • 2021-07-06
    • 1970-01-01
    • 2012-01-25
    相关资源
    最近更新 更多