6

When I run ssh-add -l, it does not show the location of the SSH key(s). It outputs the following:

4096 SHA256:bBMtB9wL6RXRWhvx5M+LDox6A2gq61CDtZN9F4bi3Gw [email protected] (RSA)
2048 SHA256:QbCO5y5SX+CSHd6++yXPpJuWGrxGCx5liNktjz51ZWY masoud@x (RSA)

How can I make it shows the key location as well?

I am running macOS Mojave 10.14.4.

2
  • Are you storing your private keys anywhere other than the standard ~/.ssh ? As far as I know, ssh-agent does not cache the filename from which a key was loaded, so there is no option to display it. You can compare fingerprints of your keys with the fingerprints listed by ssh-add -l to determine which key file corresponds to which fingerprint in the agent. Jun 5, 2019 at 14:08
  • @user4556274 no I have seen some outputs show the filename such as blog.tinned-software.net/manage-ssh-keys-with-the-ssh-agent Jun 5, 2019 at 15:33

1 Answer 1

4

ssh-agent does not cache the filename from which a key was loaded, so there is no option to display it. The third field in the output of ssh-keygen -l is a free-form comment, so you have two options to display the filename in that field when listing the keys held by the agent:

  1. When creating the key with ssh-keygen, manually specify the (expected) file path as the comment, instead of accepting the default comment:

    ssh-keygen -t rsa -b 4096 -C "/home/user/.ssh/id_rsa"
    
  2. When creating the key, manually specify no comment. If a private key has no comment, then ssh-agent will use the filename as a comment instead:

    ssh-keygen -t rsa -b 4096 -C ""
    

For keys that already exist and have a comment other than the filename, there is not a way to list the filename via ssh-add -l.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .