2

I followed some aws guide to add my private key to ssh-agent, using:

ssh-add -K "MyPrivateKey.pem"

However, I can't seem to remove the key using :

ssh-add -d "MyPrivateKey.pem"

which gives me the following error:

Bad key file MyPrivateKey.pem: No such file or directory

Unless I do ssh-add -D which removes all of the private keys I stored (obviously not favorable option). I also find that macOS ssh key management is tightly bind with Keychain, but I haven't discovered any method to identify the specific ssh key from Keychain Access. I am running on Mojave 10.14.6

tl;dr How do I get ssh-add -d to work on macOS?

1 Answer 1

3

After I post the question, I found the answer, the following command will generate the public key using the private key file:

ssh-keygen -y -f ./MyPrivateKey.pem > ./MyPublicKey.pub

then to remove it:

ssh-add -d "MyPublicKey.pub"

Reference

1
  • That's weird. man page say: "-d Deletes the given identities from the agent. The private key files for the identities to be deleted should be listed on the command line." Either way, the easiest way to drop the key in memory is to kill and restart the key-server.
    – not2qubit
    Jan 29 at 11:43

You must log in to answer this question.

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