Better SSH Remote Access

If you’re very familiar with using the ~/.ssh/authorized_keys file to allow secure, password-less SSH access to your servers, then you probably don’t need to read this post.

I have only been using this file for a short while, instead opting for the tedious (?) option of entering a password each time I connect to a host. This is mostly because I thought the process of appending your public key to the authorized_keys file was too clumsy.

Today I realized that there’s an easier way. Assuming you already have your RSA key created in ~/.ssh/id_rsa.pub (create it via ssh-keygen if not), simply issue the following command to add it to a server’s authorized_keys file:

ssh-copy-id -i ~/.ssh/id_dsa.pub user@server

When prompted, enter the password for “user” as if you were logging on to that box normally, and then test it with

ssh user@server

You should no longer be prompted for a password.