Wednesday, November 2, 2011

Adding a public key to a remote site for SSH

Adding my public key to a server is something I have to do often enough that I want it to be easier, but rarely enough that I can never remember how to do it.

The simple way to do it is to issue this command from your local terminal (note—this is all one line even though it may be broken up into multiple lines in this blog entry)

ssh-copy-id -i ~/.ssh/

This assumes you already have a working public/private key pair that you are using, and the is the public key you are sharing.

You will be asked for the password on the remote server (and your passphrase for your private key, if you are smart enough to use one of those), and if everything is in order you will be able to ssh into the remote server using your public/private key pair instead of supplying a password.