15th Jul 2008
Using rsync with no password
Ever wondered how you could use rsync in a cron job? If you worked with rsync, you would know that it uses ssh protocol, therefore you’ll need to authenticate.
One method is by providing a password. But if you don’t want to be prompted for the password (like in the use of an automated script), you can authenticate using a fingerprint key.
It’s actually very easy:
1) Generate the authentication files
As the user you are going to be running rsync as, and on the machine you will be running rsync on, type: ssh-keygen -t rsa
Follow the prompts and use the defaults for the filenames it gives you. Don’t enter in a passphrase, otherwise you will still be prompted for a password when trying to connect.
You should then have two new files in ~/.ssh, id_rsa and id_rsa.pub.
2) Copy the generated file to the remote computer
Open ~/.ssh/id_rsa.pub and copy the line in it to the ~/.ssh/authorized_keys file on the host you will be connecting to as the user you will be logging in as.
That’s it!
Ever wondered how you could use rsync in a cron job? If you worked with rsync, you would know that it uses ssh protocol, therefore you’ll need to authenticate.
One method is by providing a password. But if you don’t want to be prompted for the password (like in the use of an automated script), you can authenticate using a fingerprint key.
It’s actually very easy:
1) Generate the authentication files
As the user you are going to be running rsync as, and on the machine you will be running rsync on, type: ssh-keygen -t rsa
Follow the prompts and use the defaults for the filenames it gives you. Don’t enter in a passphrase, otherwise you will still be prompted for a password when trying to connect.
You should then have two new files in ~/.ssh, id_rsa and id_rsa.pub.
2) Copy the generated file to the remote computer
Open ~/.ssh/id_rsa.pub and copy the line in it to the ~/.ssh/authorized_keys file on the host you will be connecting to as the user you will be logging in as.
That’s it!
Posted by marian under
MAC, Linux
No Comments »