Personal tools
You are here: Home Web Server and Workstation Configuration Easier SSH with Public Keys

Easier SSH with Public Keys

This was so easy I don't know why I waited 2 years to do it.

I bet you're sick of typing your password 18 times every time you 'svn up'.  Set up public key authentication and give your fingers a rest.

Set up an ssh key pair

NB: This assumes you're environment has ssh-keygen available (Mac OSX does by default).  To generate an ssh key pair you’ll need to run the following line in your terminal:

$ ssh-keygen -t dsa

You will be asked for a location and pass phrase, and you should accept the default location (~/.ssh/id_dsa.pub) and press return when it asks for pass phrase (to give the private key a blank pass phrase).

Copy the key to the sixfeetup server (or wherever you want to log into)

After this you need to upload the public key to the server. For this we use scp. Substitute username with your own username of course (by default the user name is your local user) and server.com with your own target server where you have ssh login permissions:

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

Log into the server and set up the authorized keys file

Login to the server and append the public key you just uploaded to the authorized keys file:

$ ssh username@server.com
$ mkdir .ssh          # if it's not already there
$ cat id_dsa.pub >>.ssh/authorized_keys
$ rm id_dsa.pub       # cleanup

Tighten down permissions on your .ssh files

Initially I found that I was still unable to log in without being prompted for a password. It turns out ssh won't allow public key authentication if the permissions on the relevant files are too lax on the server side. All we need to do is reign things in a bit:

$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

After this, you should be able to login to the server and use scp as well as interact with subversion repositories without having to enter a password - woohoo!

Document Actions
« September 2010 »
September
MoTuWeThFrSaSu
12345
6789101112
13141516171819
20212223242526
27282930