header photo


Yale Astronomy

Network Tasks

Creating an SSH Key Pair for Logging in Without a Password

>> Network Tasks

If you'd like to automatically connect to SSH or SFTP into any of the computers in the lab without having to type your password every time, then you'll be interested in this tip about how to setup SSH Keys.

First install SSHKeychain

On your laptop or whatever computer you want to use to connect to the computers in the lab with, type:

ssh-keygen -t dsa

You should get a prompt:

Generating public/private dsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_dsa):

Press return to have it save the keys to the default filename id_dsa.

You will then be prompted for a password. Enter a password and then confirm it. You should then get the message:

Your identification has been saved in id_dsa.
Your public key has been saved in id_dsa.pub.
The key fingerprint is:
ac:21:c0:a7:5b:87:34:af:df:05:8c:de:f4:7f:22:1a username@computername.local
The key's randomart image is:
+--[ DSA 1024]----+
| |
| . o. . o |
| E . o + .|
| o = o |
| B . . * |
| o . * |
| . . . . . . o +|
| . o++|
| . .@|

Now copy the authorized keys from you laptop to one of the computers in the lab such as centauri:

scp ~/.ssh/id_dsa.pub username@centauri.sfsu.edu:.ssh/authorized_keys2

Note you should have been prompted for your password for the last time!

Now try SSHing into centauri:

%ssh username@centauri.sfsu.edu

You should get a prompt that looks like this:

Enter the password you used to created your key pair in step 3 and click the "Remember password in my keychain" box:

Now try connecting to centauri, 55 Cancri, or any other machine via SSH or SFTP and it should work without asking you for your password!

Return to Network Tasks