Simple passwordless SSH tutorial

It took me many attempts to work out password-less ssh, mainly because a lot of internet guides are not written that well and following them step by step didn’t work.

Then I found one that did work! Woohoo!

So I’ve copied and pasted it here… and regrettably forgotten the link I found it from. If anyone recognizes this then I’ll gladly reference it to the correct source.

The guide makes use of local$ and remote$, this is to indicate if you are typing on your local or remote server.

Create the private key


local$ ssh-keygen -t rsa (accept default file locations and create a password for your private key)
local$ scp ~/.ssh/id_rsa.pub user@remote:/home/user/
local$ ssh user@remote (enter normal root password)
remote$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
remote$ chmod 600 ~/.ssh/authorized_keys
remote$ exit
local$ ssh user@remote (at this point you shold be asked to enter the password for your private key)

Add private key password

The password for the private key needs storing in your machine. This is encrypted.

local$ ssh-agent bash
local$ ssh-add ~/.ssh/id_rsa
local$ ssh user@remote (you should no longer be asked for a password)

Note: in the code examples above, don’t type the stuff in brackets

Note 2: I think this was the blog I got the entry from, but it doesn’t work any more so I can’t be sure… I definitely looked there before I found it anyway: http://blogs.translucentcode.org/mick/archives/000230.html


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s