måndag 2 april 2012

Ssh-agent on Linux Mint 12

I have had som struggle setting up ssh agent to work with my Linux Mint machines. Both are running Linux Mint 12 and are fairly recently installed. What I want to do is to be able to log in from one host (called vader) on the other (called leia) without having to enter password every time and I don't want to generate keys with empty passwords.

First of all, I discovered that on Linux Mint 12, the firewall is turned on by default which prevented me from loging on to 'leia' with ssh. So, make sure your firewall is letting traffic through on port 22.

Now, generate keys as usual on your local host and enter a password for them:

vader$> ssh-keygen -t rsa

Install the public key on the host you want to connect to:
ssh-copy-id -i @

In my case, it looks like this:
vader$> ssh-copy-id -i ~/.ssh/id_rsa.pub peter@leia

Now, it is time to load your key into memory. This is done with the program ssh-add, but first you have to start an instance of ssh-agent.
vader$> ssh-agent bash
vader$> ssh-add

The ssh-add command will automatically load ~/.ssh/id_rsa into the agent and ask you for the password you've set. From now on I don't have to enter a password when logging in to leia, as long as I stay in the ssh-agent shell.

Good luck!