Setting up SSH to not have to enter your password every time is easy.
1. From the machine you want to connect from, create a private/public key.
air:~ user$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/user/.ssh/id_rsa.
Your public key has been saved in /Users/user/.ssh/id_rsa.pub.
The key fingerprint is:
53:32:4f:7a:36:93:f8:89:06:8f:f6:9d:a2:bf:1d:e4 user@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| o o |
| O . |
| . S O |
| + O + |
| o + E |
| . o.o o |
| .o+o+ |
+-----------------+
You can now use your public key to connect to any machine you want. All you have to do is append the public key to the ~/.ssh/known_hosts file of the machine you wish to connect to.
2. To do this, first make sure the .ssh folder exists on the machine you want to connect to. If it does not exist, create it.
air:~ user$ ssh user@computer-ip-or-host 'mkdir .ssh'
mkdir: cannot create directory `.ssh': File exists
2. Append the public key you just created to the ~/.ssh/authorized_keys file on the machine you want to connect to. Then, verify the file has the correct permissions in case it did not previously exist.
air:~ lunch$ cat .ssh/id_rsa.pub | ssh user@computer-ip-or-host 'cat >> .ssh/authorized_keys2'
user@computer-ip-or-host's password:
air:~ sdmurphy$ ssh user@computer-ip-or-host 'chmod 640 ~/.ssh/authorized_keys2'
user@computer-ip-or-host's password:
3. Now you should be able to ssh that machine without a password:
ssh user@computer-ip-or-host