Setting up and Using your public key
Public keys are a handy way to manage ssh authentication without having to type in your password. To use your public key you first need to generate one. To do this on your home machine type the following on the termninal:
Type enter to accept the default location and enter an optional passphrase. (You can leave it blank.) This creates a directory called .ssh in your home directory (hidden because of the leading period). The contents are:
The id_rsa file is your private key. Do not share it! The id_rsa.pub file is your public key, and you can share it with anyone. If you open it up it contains something like the following:
Your public key contains a method for encrypting messages that only your private key can decode. To put your public key on a server, first create the .ssh directory on the server and give it the proper permissions using chmod
Open a file called authorized_keys in the .ssh directory and paste the text of your public key in it. Then change the permissions using chmod
Now log out and log back in using ssh. If you entered a passphrase use it when prompted; otherwise you will be logged in directly without having to type a password.