Ssh – retrieve public key from ssh-agent

ssh-agentssh-keys

I am searching for a way to extract the public key from the authentication agent.
I want to be able to write the public key out into a file, after i added the key to the ssh-agent (ssh-add ~/.ssh/id_rsa).

ssh-add -l displays the fingerprint for me, but is there a way to get the complete public key?

Thank you for your suggestions

Best Answer

man ssh-add will show you all the options available. One of them is ssh-add -L. As the man page says,

 -L      Lists public key parameters of all identities currently repre-
         sented by the agent.

In other words, it will print out the public key.