Bob's Notepad

Notes on projects I have done and things I have learned saved for my reference and for the world to share

Monday, October 22, 2007

Automated SSH login using keys

I always seem to forget how to do this when I need to. When setting up an automated backup you obviously don't want the script to ask for a password so you set up a key pair.

Machine sending the backups (must be logged in as the user that will be doing the backups):

  • ssh-keygen -t dsa -b 2048 -f /any/directory/filename


Then you copy the resulting filename.pub file (NOT the file with no extension) to the authorized_keys file on the receiving machine in the .ssh directory under the user that will receive the backups. If the authorized_keys file doesnt exist, just rename the file you copied... if it does exist, append it to that file.

If your using rsync, use this command:

rsync -e 'ssh -i /any/directory/filename' source/ user@host:/destination/

Labels: , , , , ,

Reference Link


1 Comments:

Anonymous bodo said...

just a note:
on the last command, a '-' is missing in ssh command.
The correct one will look like:

rsync -e 'ssh -i /any/directory/filename' source/ user@host:/destination/

2/1/08 2:36 PM  

Post a Comment

Links to this post:

Create a Link

<< Home