startKeychain – bash utility to start ssh-agent

June 3rd, 2010 1 minute reading time.


For my (and your) future reference, here’s a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start/re-start your ssh-agent.

function startKeychain {
    killall ssh-agent
    rm ~/.keychain/*
    keychain id_rsa
    HOSTNAME=`hostname`
    source ~/.keychain/${HOSTNAME}-sh
}

Then at any time, the “command” startKeychain will be available on your command line.

Output should look something like this:


gubatron@gubatron-desktop:~$ startKeychain 

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL

 * Initializing /home/gubatron/.keychain/gubatron-desktop-sh file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-csh file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-fish file...
 * Starting ssh-agent
 * Initializing /home/gubatron/.keychain/gubatron-desktop-sh-gpg file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-csh-gpg file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-fish-gpg file...
 * Starting gpg-agent
 * Adding 1 ssh key(s)...
Identity added: /home/gubatron/.ssh/id_rsa (/home/gubatron/.ssh/id_rsa)

Comments are welcome to improve it, I’m not an ssh-agent expert, but this seems to do the work.

[SOLVED] Issue with KDE 4.4.2 and Dolphin always asking my ssh passwords whenever I browsed folder I checked out from a remote subversion repository.

Please Donate To Bitcoin Address: [[address]]

Donation of [[value]] BTC Received. Thank You.
[[error]]

One Response to “startKeychain – bash utility to start ssh-agent”

  1. Secure Automated, Key Based SSH | Steve Francia's Blog Says:

    [...] startKeychain – bash utility to start ssh-agent (gubatron.com) [...]

Leave a Reply