I do it on a regular base but everytime need to go back to my cheat sheet to jumpstart my memory.

Whenever I need to reach one system from another without asking me for a password:

First login on Server Alpha as the user desired to have the password free ssh and generate a pair of authentication keys. I would advise not to enter a passphrase but I leave that to you:

[email protected]:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:

xx:xx:xx:xx:xx:xx:xx:xx:... [email protected]
The key's randomart image is:

We need to create on the Server Bravo a user’s home subdirectory .ssh. (The directory may already exist, which is ok):

[email protected]:~> mkdir -p ~/.ssh

We now copy the key over from Alpha to Bravo

[email protected]:~> scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh/

Finally we append the new public key

[email protected]:~> cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

From now on you can log into Bravo from Alpha without any password:

[email protected]:~> ssh [email protected]

Sidenote: please make sure of the following

  • Change the permissions of .ssh to 700
    # chmod –r 700 ~/.ssh


%d bloggers like this: