0

I'm Trying to back up files with rsync over an network using ssh. And I won't be there to input the password manually. How Can I get it to put the password in automatically. My Rsync Command is this rsync -P -r --delete --checksum USER@IPADDRESS:/home/USER/dir1 /home/USER/dir2

1 Answer 1

0

Though this is not exactly the question, may I suggest using a ssh public/private key pair instead?

Generate a key pair on the initiating side with ssh-keygen, then transfer the public key into ~/.ssh/authorized_keys on the target There will be tons of howtos for the exact steps on the net, I will not reproduce them here.

You can then invoke rsync with the extra option -e "ssh -i /path/to/private_key"

If you do not specify a passphrase when creating the key, this will allow you to rsync without entering a password. Be aware though, that this private key file effectively will be a password to your remote account. Anyone with access to that file will be able to log in to the remote side. But that would also be the case for anyone grabbing your password from the command line if you managed to add it by a parameter to rsync, so no big difference maybe.

A better way might be to add a passphrase, but unlock the key with the ssh agent. rsync should pick that up if run for the same user. But this will not always work when used in a script, e.g. from cron.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .