I can add pem files to my SSH agent very easily using ssh-add
, like so:
$ ssh-add /home/jsmith/keys/mytest.pem
But I can't seem to remove them:
$ ssh-add -d /home/jsmith/keys/mytest.pem
Bad key file /home/jsmith/keys/mytest.pem: No such file or directory
The pem file still exists though... I haven't moved or changed it in any way. Why am I having so much trouble removing this pem file from my SSH agent that I just added a moment ago? What's the correct way to do this?
I want to avoid using ssh-add -D
(with a capital "D") because that would delete all of the identities from my SSH agent, and I only want to delete the one I've specified.
Go to System --> Preferences --> Startup Applications , and unselect the " SSH Key Agent (Gnome Keyring SSH Agent) " box -- you'll need to scroll down to find it. You'll still get an ssh-agent , only now it will behave sanely: no keys autoloaded, you run ssh-add to add them, and if you want to delete keys, you can.
If your private RSA key is not encrypted with a passphrase, then ssh-agent is not necessary. The ssh command would be an example of a client.
You have to use the public key for this. So first extract the public key and then remove it from the agent.
ssh-keygen -y -f /home/jsmith/keys/mytest.pem > /home/jsmith/keys/mytest.pub
ssh-add -d /home/jsmith/keys/mytest.pub
The man page mentions the "public" key as well: "if no public key is found at a given path, ssh-add will append .pub and retry".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With