Locally keys made available by ssh agent can be listed using ssh-add -L. When connected to a remote machine through ssh, is there a way to list keys made available through ssh agent from the local machine?
1 Answers
You do forward the local agent, right? If so, then the command is the same: ssh-add -L. ssh-add connects to the socket specified by $SSH_AUTH_SOCK and if you have used ssh -A then the remote socket leads to your local agent and thus remote ssh-add (or any tool that uses the socket) will talk to the local agent.
You can even ssh-add a remote key (remote from your point of view; local from the point of view of ssh-add running on the server) and your local agent will be able to use it even after you disconnect.
(More complicated tricks are possible. E.g. this answer of mine describes "borrowing" keys, but in the opposite direction: a local key is added to an agent running on the server.)
Note ssh-add -L will show you pathnames of added keys with no indication of where (what host) each key came from. You can add one key with ssh-add /foo/bar locally and you can add another key with ssh-add /foo/bar invoked on the server (when the agent is forwarded!), and ssh-add -L (locally or on the server) will show you two different keys described as /foo/bar.
- 69,815
- 22
- 136
- 202