5

I had several old ssh keys in my ~/.gnupg/sshcontrol so I removed all lines in this file and rebooted my computer. Now, I can't add ssh keys to gpg agent anymore:

$ cat ~/.gnupg/gpg-agent.conf 
enable-ssh-support

$ gpg-connect-agent --verbose /bye
gpg-connect-agent: closing connection to agent

$ gpg-connect-agent updatestartuptty /bye
OK

$ ssh-add -l
The agent has no identities.

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/cassou/.ssh/id_rsa: 
Identity added: /home/cassou/.ssh/id_rsa (/home/cassou/.ssh/id_rsa)

$ ssh-add -l
The agent has no identities.
  • Did you try the --enable-ssh-support switch? – Jakuje Feb 28 '16 at 21:15
  • I've updated my post to answer your question. The gpg-agent.conf contains the directive to start the ssh support. – Damien Cassou Mar 1 '16 at 10:38
6

I had the same issue and this is how I resolved it:

gpg-agent copies keys that you add with ssh-add to a special directory under ~/.gnupg (specifically ~/.gnupg/private-keys-v1.d with gpg2).

It seems, and I really think this should be reported as a bug, that if the key you're trying to add with ssh-add already exists in that directory it won't actually add the key to ~/.gnupg/sshcontrol which in turn means it won't be presented by gpg-agent. Running grep -aoe "comment.*$" ~/.gnupg/private-keys-v1.d/* should print out a comment that (at least for me) corresponded to which key was which.

Once you remove the specific key and try adding again it should work. I'd advise against clearing the whole directory as this is also where it caches your gpg keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.