Search code examples
sshdebianssh-keygen

Using rsync with ssh keygen


I have a Debian server and I want to make a cron to save datas from my server to a remote hard drive connecting to my mac.

So, I made this command which run correctly :

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

but I have to enter a password.

I used ssh-keygen to make the file id_rsa_lb (not id_rsa) and I sent it with

ssh-copy-id -i ~/.ssh/id_rsa_lb.pub 1xx.1xx.1xx.1xx

The command ssh -i ~/.ssh/id_rsa_lb lxxxxxxxxxx@1xx.1xx.1xx.1xx runs correctly and doesn't need any password. It's OK.

But when I try to run the rsync with the ssh/id_rsa_lb, I have an error :

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]

Can you tell me what is wrong ?

Thanks


Solution

  • Use quotes, -e expects exactly one argument.

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