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:
$> ssh-keygen
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:
$> ls .ssh
id_rsa id_rsa.pub
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:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5/Sv6el1KPe8DbihilmigqN04qi
iaFb4yXqOyK1Z4EN9YCICAwLCVkhr3ZQbLLmelhrS0nPY6KJLOL0Md4Z8U5ecQI9AF
jgo/qD/kxkSzE04ZNdizZMIVz/3jO9feU5fxFn/ZENDc+7za7inAyvpsQpTSzUjSOE
VbTZD7Pq3MHfnCbgPRLiN0yHJzpuayNN3UQiLmvzL2PPPRvm18yMFYq6a5U9OX6CQK
dZJ63XgV/nZKbk3gArguYL51Qp70f/1b3Ej8B6yKilI8ZocfP7jIdu5La+wpYOInR2
rUu+pl3sBdMZcgkaZOpoU/miT42Kf2SBQYUH48dRs5YBu1tBZD me@mylaptop
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
$> mkdir .ssh
$> chmod 700 .ssh
$> cd .ssh
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
$> chmod 600 authorized_keys
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.