Generating SSH Keys For Password-less Backups

It is not practical for you to have to enter your password during automated or scheduled backups. If your backups must prompt for your password then the backups will most never complete unless you are present every time they start. This guide should be the same for Linux / Unix / BSD / Mac OS X. Windows users will have to rely on either their backup software or a separate program to maintain SSH keys.

Open A Terminal

Log into your system as the user that will be running the backups. If necessary open a terminal window if this is being done from your local machine. If you are setting this up on a remote server then just SSH into the server as the user you will create the key for.

This can be done either from the machine you are backing up for PUSH backups, or this can be done from the rSyncIT server for PULL backups.

The user you create the key for will have to be the user that runs the backups since no other user can access your SSH keys.

Mac OS X: Applications > Utilities > Terminal
Linux: Open your favorite terminal application or if you have a multiplexed terminal CTRL+ALT+F1 (or any of the F1-F6 keys).
Unix/BSD: Most unix and BSD distributions do not come with a X window environment and therefore you should already be at a prompt or SSH'd into it.


Run the following command. Accept the defaults to every prompt by hitting ENTER.
If you store the key in a different location than the default you will have to specify it's location each and every time you want to use it.
If you enter a passphrase then that will defeat the purpose of creating a password-less key for backups.

ssh-keygen -t rsa


Copy The Public Key To The Remote Host

To copy the newly created public key to the remote host use the following command. The remote host could be our server or it could be your server. Depending on if you are doing a PUSH or PULL backup.
You will have to remember to replace 'rsyncitusername' and '' with your correct username and sub-domain respectively. It will be necessary to enter the password for this user for this command.

cat ~/.ssh/ | ssh \ 'mkdir-p ~/.ssh/ && cat - >> ~/.ssh/authorized_keys

A brief explanation of what this command does
It first dumps (cat) the information in the ~/.ssh/ file and then "pipes" ( | ) that data via SSH to the remote server and ensures the .ssh directory exists, and then ultimately uses the same program that dumps (cat) the information to dump it back into a file on the remote system.

Testing The Password-less SSH Login

To ensure that the new key is now working properly you can run the following command as a quick test.

ssh ls

The output of the command should give you a list of your home directory on the remote server.