Setting up SSH Public Key Authentication

These instructions will allow you to connect as user1 on machine FROM to user2 on machine TO without typing your password for the ssh and scp commands. This can be very useful when doing batch copies (e.g. using to copy many directories of breseq results) or for machines that you constantly find yourself needing to login to.

Step 1: Log into machine FROM as user1. Run the ssh-keygen command. Leave the passphrase empty. (Just hit return when prompted for the passphrase.)

$ ssh-keygen
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
The key fingerprint is:
d2:e1:78:ac:c1:13:01:f2:a7:84:94:7d:a6:06:f8:1a lab@backup
The key's randomart image is:
+--[ RSA 2048]----+
| .oo...          |
|..o+. o.         |
| ...o+o .        |
|E ..o+ * .       |
| o .. * S        |
|.      *         |
|      .          |
|                 |
|                 |

Step 2: create the ssh directory on machine TO as user2, if it does not exist:

$ ssh user2@TO mkdir -p .ssh
user2@TO's password: 

Step 3: Add the key that we just created for user1 on FROM as a new line in the .ssh/authorized_keys file in account user2 on machine TO.

$ cat .ssh/ | ssh user2@TO 'cat >> .ssh/authorized_keys'
user2@TO's password:

To add login to additional remote machines, repeat Step 3.


 Barrick Lab  >  ProtocolList  >  ProtocolsSSHPublicKeyAuthentication

Topic revision: r1 - 24 Dec 2012 - 16:31:11 - Main.JeffreyBarrick