<br><br><div class="gmail_quote">On Feb 8, 2008 10:58 AM, Jeff Quast <<a href="mailto:af.dingo@gmail.com">af.dingo@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I wrote something similar to keychain and keep it in some .profile's.<br>It has worked on all ksh or bash machines i've been on so far. pgrep<br>is needed, though you can hack around it.<br><br>just remember to _LOCK_ your ssh agent when you're away, since your<br>
keys are loaded in memory. gnu/screen can be locked, too, if thats<br>your poison, but it would be better to lock both. I had aliases like<br>alias lock='ssh-add -x; xlock' or something like that. You can<br>probobly get lost in thousands of lines of screen info pages to figure<br>
out how to make screen lock both your ssh keys and your gnu/screen<br>with a new key-binding.<br><br>Sorry of this script is redundant to the topic, but I noticed the<br>referenced 'keychain',<br><a href="http://www.gentoo.org/proj/en/keychain/index.xml" target="_blank">http://www.gentoo.org/proj/en/keychain/index.xml</a> , is not available,<br>
as it says 'source tarballs available...' to a dead link. emerge and<br>rpm only i guess. Typical gentoo/linux style to over-engineer and<br>evolve into deprication while maintainers abandon ship.</blockquote><div>
<br>I found a NetBSD package with this the Gentoo keychain script here: <a href="http://pkgsrc.se/security/keychain">http://pkgsrc.se/security/keychain</a><br>and a FreeBSD port here: <a href="http://www.freshports.org/security/keychain/">http://www.freshports.org/security/keychain/</a><br>
and a tarball here: <a href="http://www.net-security.org/software.php?id=239">http://www.net-security.org/software.php?id=239</a><br>
<br>I can also verify that "keychain" works on Solaris as well as Linux and BSD.<br><br>(I don't know how keychain compares to your script, but it does look good.)<br><br>(Frankly it's one of those things that just works, and I suspect once they had it tested and working on most of the major platforms there was little need for further development.)<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"># point to one or more ssh keys<br>keys="$HOME/.ssh/rsa-key*"<br><br>build_keychain() {<br>
export keychain=$(ssh-add -l | awk '{ if ( $3 != "has") print $3 }')<br> let numkeys=0<br> for k in $keychain; do let "numkeys++"; done<br> export numkeys<br>}<br><br>
ison_keychain() {<br> for key in $keychain; do<br> [ X"$key" == X"$*" ] && return 0<br> done<br> return 1<br>}<br><br>if [ -o interactive ]; then<br> if [ X"${keys}" != X"" ]; then<br>
# start agent if not running<br> pgrep -U $USER ssh-agent 1>/dev/null 2>&1<br> if [ $? -ne 0 ]; then<br> rm -f $HOME/.ssh/agent.$(hostname) # remove stale socket<br>
eval `ssh-agent -s -a $HOME/.ssh/agent.$(hostname)`<br> fi<br><br> # export agent socket<br> [ -r $HOME/.ssh/agent.$(hostname) ] \<br> && export SSH_AUTH_SOCK="$HOME/.ssh/agent.$(hostname)"<br>
<br> # add keys not on keychain<br> build_keychain<br> for add_key in $keys; do<br> if [ -f $add_key ]; then<br> ison_keychain "$add_key"<br>
[ $? -eq 1 ] && ssh-add $add_key<br> fi<br> done<br><br> # echo number of keys in keychain<br> build_keychain<br> if [ X"$keychain" == X"" ]; then<br>
echo keychain is empty<br> else<br> echo -n $numkeys key<br> [ $numkeys -ge 2 ] && echo -n s<br> echo ' in keychain'<br>
fi<br> fi<br> # $back becomes IP of originating SSH connection, for instance,<br> # scp file $back:<br> back=$(echo $SSH_CONNECTION | awk -F[=\ ] '{ print $1 }')<br><br>
if [ X"$keychain" != X"" ]; then<br> echo "SSH Forwarding of authentication agent enabled"<br> # cheap hack, (re-use 'wssh' hook from /etc/ksh.kshrc)<br>
[ alias | awk -F "['\ ]" '/^ssh/{print $2}' ] \<br> && alias ssh='wssh -A' \<br> || alias ssh='ssh -A'<br> fi<br>fi<br>
<div><div></div><div class="Wj3C7c">_______________________________________________<br>talk mailing list<br><a href="mailto:talk@lists.nycbug.org">talk@lists.nycbug.org</a><br><a href="http://lists.nycbug.org/mailman/listinfo/talk" target="_blank">http://lists.nycbug.org/mailman/listinfo/talk</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>- Brian Gupta<br><br><a href="http://opensolaris.org/os/project/nycosug/">http://opensolaris.org/os/project/nycosug/</a>