Raspberry Pi How To: Use SSH key for login

Terminal login can be performed without the need to enter a password every login session.

You need to generate a RSA key pair and then place the public key into the servers "authorized_keys" file.

First check if the RSA key pair is already present in the users ~/.ssh directory. The default names of the two key files are "id_rsa" and "id_rsa.pub", however, they could have a different name. One of the files should have a ".pub" extension.

If the key files need to be generated you can use the following command:

ssh-keygen -t rsa 

In the following dialog you can decide if you want to use a passphrase. For a key without pass phrase just press enter (empty pass phrase).

To transfer the public key in the file on the server you can use this command:

ssh-copy-id user@123.45.56.78

ssh-copy-id does not come with plain OS X, it is part of the XCode command line utilities which are available for download.
There are a couple of other options to transfer the file.
You can manually copy the contents of ~/.ssh/id_rsa.pub from your client into the ~/.ssh/authorized_keys file on the server. The key is on a single line, no line breaks allowed.

Or you can use secure copy:

scp ~/.ssh/id_rsa.pub username@192.168.x.x:~/.ssh/newkey

Once the new key is on the server you can rename the file to "authorized_keys" or, if you already have and authorized_keys file, you can append the new key to the existing file:

cat newkey >> authorized_keys