Logging into many a remote hosts and, or servers from my desktop and, or notebook is a routine job for me, hence I extensively use ssh and ssh-agent every day. I wanted to use the same ssh-agent instance from each and every terminal whether I’m on a virtual console or in front of x-window desktop running a terminal emulator. I created a tiny bash script say ssh-agent.sh in the /etc/profile.d as follows:
SSH_ENV="$HOME/.ssh-agent.env"
start_agent() {
# Run ssh-agent, only if root is mounted in read-write mode
if grep -q '\ /\ ext.*rw' /proc/mounts; then
ssh-agent |sed 's/^echo/#echo/' >"$SSH_ENV"
chmod 600 "$SSH_ENV"
. "$SSH_ENV" >/dev/null
fi
}
# Source SSH settings, is ssh-agent already running, eh
if [ -f "$SSH_ENV" ]; then
. "$SSH_ENV" >/dev/null
pgrep ssh-agent |grep -q $SSH_AGENT_PID || start_agent
else
start_agent
fi
And the life now seems quite easier since then
Maybe you should try Gentoo Keychain. it is your script + tidy and clean + support for gpg-agent :). Happy ssh-ing