Linux Tip: Setting up key-based authentication.

In this post I’ll explain how to use key-based SSH authentication in Linux.

This can be used either for non-password based authentication for scripts or other utilities, or for extra security when paired with a pass phrase key.

We’ll need to generate a key-pair, a public-key and a private-key. The public-key will be placed on the server, and you will log in with your private-key. You will need to enter a passphrase for security (or leave blank for password-less auth.)

First generate the key:

ssh-keygen -t rsa -b 1024 -C “your-email-address”

This will create a 1024 bit key using RSA in your current directory. You will need to transfer it to the server you wish to authenticate with by some means, you can use SCP if you have an SCP client like this:

scp -p id_rsa.pub user@server:~/

Then log in to the remote server, and put the file in the authorized_keys for the user you want to authenticate with.

This entry was posted
on Wednesday, November 11th, 2009 at 4:05 pm and is filed under Technology, tips.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.