Generating your keys
To use keys for SSH authentication, you will firstly need to generate your public and private keys. In this example, we will be using the DSA algorithm.
# ssh-keygen -t dsa
You should then see the following:
Generating public/private dsa key pair. Enter file in which to save the key (/home/andy/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/andy/.ssh/id_dsa. Your public key has been saved in /home/andy/.ssh/id_dsa.pub. The key fingerprint is: 12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef andy@sway
When ssh-keygen asks you in which file you want it to save the key, just press hit enter to use the default path.
To use password-less authentication, just hit enter when it asks for a password.
Your keys have now been generated. The should look like the following:
# ls -l ~/.ssh/id_* -rw------- 1 andy andy 744 Jun 25 09:27 .ssh/id_dsa -rw-r--r-- 1 andy andy 598 Jun 25 09:27 .ssh/id_dsa.pub
The id_dsa key is your private key. You should keep this in a safe place. Also, be sure it is only readable and writable by only you. If the permissions don't look like the listing above, then you should run
# chmod 600 ~/.ssh/id_dsa
The id_dsa.pub key is your public key, which will be need to be added to systems you want to have access to.
NOTE: ~/.ssh/ should be chmod'd 0700, for security matters.
drwx------ 2 andy andy 598 Jun 25 09:31 .ssh/
Placing the key on the remote server
Before you'll be able to login using your key, you must first copy your public key into the file authorized_keys which is located in your ~/.ssh/ directory.
Do as follows:
# cat ~/.ssh/id_dsa.pub | ssh hostname "cat >> .ssh/authorized_keys"
Currently, on my server, no access is allowed by passwords. This means that you will not be able to get in, until your key has been set up. Therefore, you'll have to get me to disable it for you for a little while so you can get in and install your key.

