Loading...
Life's Curriculum
by Bart Kus - email "me" at this domain
Life's Curriculum
History: Automatic ssh-agent management
View page
Source of version: 2
(current)
Managing ssh-agent / ssh-add is a pain. If you slap the following into your ~/.bashrc (or equivalent): {CODE(caption="Easy ssh-agent / ssh-add system",wrap="0",ishtml="0")}AGENT_FILE=$HOME/.ssh/ssh_agent test -e $AGENT_FILE && . $AGENT_FILE test -n "$SSH_AGENT_PID" && ps --no-headers -f -p $SSH_AGENT_PID | grep -E "^$USER.*ssh-agent$" >/dev/null if [ $? -gt 0 ] then ssh-agent | grep -v echo > $AGENT_FILE fi . $AGENT_FILE ssh-add -l >/dev/null if [ $? -gt 0 ] then ssh-add fi {CODE} It'll start the ssh-agent if it's not already running, check to see if you have any keys loaded, and if not will prompt you to load your default identity. Once loaded, you can logout, or login multiple times and you'll always have your identity associated with your session. The persistence is handled through the $AGENT_FILE. Should ssh-agent die or the system reboot, everything will work as you'd expect it to (ie: start new ssh-agent, prompt to load identity again).
Source
Comments
Menu
Home
Wiki
Wiki Home
Last Changes
List Pages
Structures
Blogs
List Blogs
Rankings
File Galleries
List Galleries
Log In
Username:
Password:
CapsLock is on.
Log in
I forgot my password
Register