Techy: Setting up Private Key Authentication in Linux for Rsync

July 13th, 2007 by Richy B. Leave a reply »

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.

This post is over 6 months old.

This means that, despite my best intentions, it may no longer be accurate.

This blog holds over 12 years of archived content - during that time, I may have changed my opinion of something, technology will have advanced (and old "best standards" may no longer be the case), my technology "know how" has improved etc etc - it would probably take me a considerable amount of time to update all the archival entries: and defeat the point of keeping them anyway.

Please take these posts for what they are: a brief look into my past, my history, my journey and "caveat emptor".

Leave a Reply

gamy-dance
%d bloggers like this: