将 rsync 与 ssh keygen 结合使用

Using rsync with ssh keygen

我有一个 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]

你能告诉我哪里出了问题吗?

谢谢

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

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