An SSH key is a secure encrypted code that allows you to connect to a server without having to type the password in plain text. To setup a key, follow these instructions:
1. First you need to connect to an SSH host on each machine (this will create the .ssh directory in your home directory):
2. On the local machine, type:
ssh-keygen -t dsa
It will prompt you for the secret passphrase. After you enter the passphrase, it will create id_dsa and id_dsa.pub in the /home/user/.ssh directory.
3. Next copy the above-mentioned files to the remote server:
scp ~/.ssh/id_dsa.pub yourdomain.com:.ssh/authorized_keys2
4. Now tell your server which key to use:
ssh-agent sh -c 'ssh-add < /dev/null && bash'
It will ask your for your passphrase and create a new bash shell.
5. Finally, type
ssh yourdomain.com (It should now connect without asking you for a password).
Photo Source: Wikimedia Commons