[Cialug] enter passwords less
Jeffrey C. Ollie
jeff at ocjtech.us
Mon Aug 20 16:06:57 CDT 2007
On Mon, 2007-08-20 at 15:17 -0500, Matthew Nuzum wrote:
> Goal is to unlock ssh key first time its used then not need to enter
> ssh key's password again until you log out.
>
> This works:
>
> if [[ ! `ssh-add -l|wc -l` > 0 ]]
> then
> ssh-add
> fi;
>
> This doesn't:
>
> alias ssh='if [[ ! `ssh-add -l|wc -l` > 0 ]];then ssh-add; fi; ssh'
>
> Instead I'm always asked to decrypt my ssh key.
I think that your problem is this:
$ ssh-add -d
Identity removed: /home/jcollie/.ssh/iddsa
(/home/jcollie/.ssh/iddsa.pub)
$ ssh-add -l
The agent has no identities.
So when ssh-agent doesn’t have your identity cached it still prints a
line of text which messes up the comparison. However, by checking the
exit code of ‘ssh-add -l’ I was able to get it to work:
alias ssh='if ! ssh-add -l >/dev/null 2>&1; then ssh-add; fi; ssh'
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://cialug.org/pipermail/cialug/attachments/20070820/722cd642/attachment.pgp
More information about the Cialug
mailing list