Creating an SSH Key Pair for Logging in Without a Password
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:
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 email@example.com:.ssh/authorized_keys2
Note you should have been prompted for your password for the last time!
Now try SSHing into centauri:
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