[PATCH v2] ssh-add: support external parsing of key listing

Corey Hickey bugfood-ml at fatooh.org
Sat Jan 11 06:00:33 AEDT 2025


On 2025-01-10 09:33, Morgan, Iain (ARC-TN)[InuTeq, LLC] via openssh-
unix-dev wrote:
> What about simply modifying your script?  For example, instead of
> simply doing "ssh-add -l," you could use "ssh-add -l | grep
> SHA256."  This would eliminate any non-key output to stdout, but
> admiteedly assumes that the fingerprint algorithm does not change.

Thanks but I think that also can't differentiate between "no keys in 
agent" and "agent not present/not working".

The check I have in place currently is:

if ! KEY_LISTING=$(ssh-add -l) ; then
     if [ "$KEY_LISTING" = "The agent has no identities." ] ; then
         KEY_LISTING=""
     else
         echo "SSH agent error" >&2
         exit 2
     fi
fi

I did think it would be nicer in the long run to get a change in 
upstream to make this easier.

Thanks,
Corey


More information about the openssh-unix-dev mailing list