make ssh-add conditional?
openssh at yarra.no-ip.org
openssh at yarra.no-ip.org
Thu Aug 17 21:42:08 EST 2006
Hi folks, I don't know if this has been suggested and knocked back before - I
didn't find it while googling. Anyway, I'd like ssh-add to have an option to
add a key only if it is not already present in ssh-agent. I currently use a
shell function to conditionally add a key, then login to a remote host:
go ()
{
ssh-add -L | grep -q 'id_rsa_mykey$';
if [ $? -eq 0 ]; then
echo "my key already present";
else
ssh-add ~/.ssh/id_rsa_mykey;
fi;
if [ $? -eq 0 ]; then
ssh myhost;
else
echo "Oopsie";
fi
}
It works well enough, but it seems inelegant - I'd prefer if ssh-add had this
built-in already, so I could do something like:
go()
{
ssh-add ~/.ssh/id_rsa_mykey && ssh myhost
}
...and ssh-add would not ask me for the passphrase if the key was already
present, and exit 0.
Is it feasible? Would it be useful? If I make a patch for it, would it stand a
chance of being accepted?
Regards, Philip.
More information about the openssh-unix-dev
mailing list