Press "Enter" to skip to content

Techy: Setting up Private Key Authentication in Linux for Rsync

If you wish to be able to automatically log in from one (server a) to another (server b), or you wish to setup rsync so that you can automatically send your backups from “server a” to the remote backup server “server b”, then the following steps should help in the configuration of this:

  • Login to server “A” via SSH as root
  • See if an RSA encryption key already exists by typing the following command:
    cat ~/.ssh/id_rsa.pub
    If the key does NOT exist (i.e. you do not receive any output or the system reports “No such file or directory”), then you’ll need to generate an RSA encryption key using the command:
    ssh-keygen -t rsa -N ''
    (note: those are two single quotes and NOT a double quote)
    You’ll then be prompted where to save the key (it should auto-suggest something like /root/.ssh/id_rsa which you should accept)
  • Now you’ll need to copy the RSA encryption key to the remote server (server B). Still via SSH on server A”, enter the following commands (replacing serverb.example.com with the name/IP address of server B, and entering server B’s password where prompted):
    ssh serverb.example.com
    mkdir .ssh
    exit
    scp ~/.ssh/id_rsa.pub root@serverb.example.com:/root/.ssh/remotekey
    ssh root@serverb.example.com
    cd .ssh
    cat remotekey >> authorized_keys

    exit

  • Now typing “ssh root@serverb.example.com” from server A should automatically log you in.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.