Follow the instructions below to create and install a SSH public key on your remote server. After you followed these steps your able to login via SSH without entering a password. This is extremely useful for backups with rsync or for other automatic tasks you like to execute.
- Change to your user’s home directory (local system)
- create a pair of private keys
ssh-keygen -f .ssh_key -t rsa -N ''
- *** upload the public key to the remote system using rsync via SSH
rsync -e ssh ~/.ssh_key.pub user@YourServer:key1.pub
- login to your server via SSH using the command line or Putty
(you need to enter your password too)
- check if the .ssh directory exists, if not create it
- add the public key to the user authorized key files
cat key1.pub >> .ssh/authorized_keys
- remove the uploaded key from your home directory (remote system)
- test your new “private” connection
rsync -avz -e "ssh -i .ssh_key" "someFolder" user@YourServer
Now you’re able to access the remote system (YourServer) from your local system without using a password. This tutorial is for Linux only.
*** UPDATE: 12th december 2011
If you can’t create a persistent SSH connection to you backup server this way you need a small workaround:
After the creation of your “local” keys you need to download the “authorized_keys” file from the backup serverrsync -e ssh user@YourServer:.ssh/authorized_keys ~/authorized_keys
(check the exact locations first)
Now add your public key to the downloaded filecat .ssh_key.pub >> authorized_keys
Upload the modified “authorized_keys” file to the backup serverrsync -e ssh ~/authorized_keys user@YourServer:.ssh/authorized_keys
Remove the downloaded file and test you connection like described in step 8.
4 thoughts on “SSH Authentication without entering a password”
I use public SSH keys in many cases: I install a key from my hosting provider and provide him access to my server (much better then sending root passwords by mail). I create daily backups using rsync, using keys is a requirement here ;)
Right you need a password-less authentication for your backups. I use rsync also to publish new or changed websites, using a list of standard comments can safe a lot of your time.
It's a secure and user friendly method for Linux users. I'm working on Windows and I'm not able to create the SSH keys. Is there anyone with a suggestion?
I searched Google for "create ssh key windows" and found this information
It seems like that Putty has a function to create SSH key pairs
Comments are closed.