When you want to use ssh with keys, the first thing that you will need is a key.
creating key using dsa encryption (or replace dsa by rsa for rsa encryption)
$ ssh-keygen -t dsa
When asked for a "passphrase", we won't enter one. Just press enter twice.
The ssh-keygen program will now generate both your public and your private key, by default, your keys are stored in the .ssh/ directory in your home directory.
To be able to log in to remote systems using your pair of keys, you will first have to add your public key on the remote server to the authorized_keys file file in the .ssh/ directory in your home directory on the remote machine.
$ cd ~/.ssh; scp id_dsa.pub username@target:./id_dsa.pub
$ ssh username@target
$ mkdir ~/.ssh; chmod 700 ~/.ssh
$ cat id_dsa.pub >> ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
$ rm -fr id_dsa.pub
You can now ssh to the remote systems's account without the use of a password.