0

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

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

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

then to remove it:

ssh-add -d "MyPublicKey.pub"

Reference

You must log in to answer this question.

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