160

How and where can I check what keys have been added with ssh-add to my ssh-agent ?

198

Use the -l option to ssh-add to list them by fingerprint.

$ ssh-add -l
2048 72:...:eb /home/gert/.ssh/mykey (RSA)

Or with -L to get the full key in OpenSSH format.

$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc[...]B63SQ== /home/gert/.ssh/id_rsa

The latter format is the same as you would put them in a ~/.ssh/authorized_keys file.

  • 1
    [rahul@srv1~]$ ssh-add -l Could not open a connection to your authentication agent. – Rahul Patil Dec 20 '12 at 11:11
  • 1
    @RahulPatil Are you running an SSH agent on that machine? Run this on the same machine as to which you've added the keys, not the remote one! – gertvdijk Dec 20 '12 at 11:18
  • 4
    You could run this command on the remote host if key agent forwarding is enabled. – Patrick Mar 30 '13 at 19:58
  • 3
    Example: ssh-agent sh -c 'ssh-add; ssh-add -l' – kenorb Mar 26 '15 at 21:15
  • @RahulPatil To run the ssh agent eval `ssh-agent -s`. stackoverflow.com/questions/17846529/… – Clay Jul 28 '15 at 17:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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