I've currently an old SSH key uploaded on the server. The problem is I lost my ~/.ssh
directory (with the original id_rsa
and id_rsa.pub
files).
Consequently, I want to remove the old SSH key directly on the server and upload a new one.
I tried the following command without success:
$> ssh-add -D
Is there a way to completely remove a SSH key?
Note that there is at least two bug report for
ssh-add -d/-D
not removing keys:ssh-add -D
does not remove SSH key fromgnome-keyring-daemon
memory"ssh-add -D
deleting all identities does not work. Also, why are all identities auto-added?"The exact issue is:
More precisely, about the issue:
This bug is still confirmed in Ubuntu 14.04.4, as recently as two days ago (August 21st, 2014)
A possible workaround:
Another workaround:
This comments actually suggests:
If you're trying to perform an ssh-related operation and get the following error:
You can remove the missing ssh key from your ssh agent with the following:
Unless I'm misunderstanding, you lost your
.ssh
directory containing your private key on your local machine and so you want to remove the public key which was on a server and which allowed key-based login. In that case, it will be stored in the.ssh/authorized_keys
file in your home directory on the server. You can just edit this file with a text editor and delete the relevant line if you can identify it (even easier if it's the only entry!). I hope that key wasn't your only method of access to the server and you have some other way of logging in and editing the file. You can either manually add a new public key toauthorised_keys
file or usessh-copy-id
. Either way, you'll need password auth set up for your account on the server, or some other identity or access method to get to theauthorized_keys
file on the server.ssh-add
adds identities to your ssh agent which handles management of your identities locally and "the connection to the agent is forwarded over SSH remote logins, and the user can thus use the privileges given by the identities anywhere in the network in a secure way." (man page), so I don't think it's what you want in this case. It has no way to get your public key onto a server without you having access to said server via an ssh login as far as I know.I opened "Passwords and Keys" application in my Unity and removed unwanted keys from Secure Keys -> OpenSSH keys And they automatically had been removed from ssh-agent -l as well.
Simplest way would be