Generating SSH Keys - Using Keychain and SSH Agent
Written by Sam Moffatt   
Tuesday, 16 October 2007 05:15
Article Index
Generating SSH Keys
Generating a key
Transferring your key
Using an SSH Agent
Keychain and SSH
SSH and GNOME
Wrapping Up
All Pages

Using Keychain and SSH Agent

Keychain (http://www.gentoo.org/proj/en/keychain/) is tool that aids the user in finding an existing ssh-agent or creating a new one (not to be confused with the Keychain tool for GNOME or Mac OS X). Keychain is available on Debian systems via APT and Gentoo via emerge. You can acquire the source from the above stated URL. I personally use Keychain on my Mac because it is the easiest way of managing SSH keys because I run it in my BASH start up:

keychain source ~/.keychain/$(HOSTNAME)-sh

On login I see this message (or messages saying its creating various files for me, see next example)

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL
* Found existing ssh-agent (250)

This finds an existing ssh-agent session and connects me to it. The first time it runs we have to still add our passphase using ssh-add:

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL
* Initializing /Users/moffats/.keychain/bigmac-sh file...
* Initializing /Users/moffats/.keychain/bigmac-csh file...
* Initializing /Users/moffats/.keychain/bigmac-fish file...
* Starting ssh-agent
bigmac:~ moffats$ ssh-add
Enter passphrase for /Users/moffats/.ssh/id_rsa:
Identity added: /Users/moffats/.ssh/id_rsa (/Users/moffats/.ssh/id_rsa)

Once we've done this, we don't need to run ssh-add until we next reboot as Keychain will continue to find the existing session. It will fail if your hostname changes on your machine, however this is usually only an issue for laptops (specifically ones that are set to reconfigure their hostname based on their DNS name, such as Mac's).



Last Updated on Wednesday, 09 April 2008 06:57