Tuesday, August 25, 2009

New Direction (and url!)

It's been suggested by several of my friends that I turn this space into random snippets of linux/programming knowledge. I make no commitments as to the frequency of said posts. I'll try to throw things up here as I'm inspired. Also, you get bonus points if you find this at the new url.

So, without further ado:

If you're in a situation where ssh-agent isn't running farther up in your process tree automatically, here's how to get the same functionality out of .bashrc.

export EDITOR=/usr/bin/vim

SSH_ENV="$HOME/.ssh/environment"

function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi

1 comment:

Ryan said...

The syntax highlighting on this page isn't quite right yet. I'm leaving it broken as I've submitted this page as an example in the bug report to SyntaxHighlighter. The view source link does give you the correct text. Once the kinks are ironed out, I'll post (yet another) howto for getting it working with Blogger.