Setting up SSH keys is easy

Sunday, October 16

You can use SSH Keys to avoid having to enter your password when you log in to a remote machine. Think of your key as being your computer’s unique thumbprint. When you ssh into another computer, your thumbprint is checked against a list of pre-authorized thumbprints and if a match is found, you’re allowed in—no password required.

If you’ve never done this before, you’ll need to create a DSA key pair (the thumbprint). You only need to do this once.

$ ssh-keygen -d

Just hit enter to accept the defaults, and leave the passphrase blank. Your public key will be saved to the file ~/.ssh/id_dsa.pub

Now that you have a key, all you have to do is copy it to the authorized_keys file on the machine you want to log in to.

$ scp ~/.ssh/id_dsa.pub username@example.com:~/.ssh/authorized_keys

Nice. Now you’ll be able to log in without your password, which is really helpful when you want to do things like schedule backups using rsync, or if you’re lazy.

Just don’t lose your laptop.