问题描述
我目前在服务器上上传了旧的SSH密钥.问题是我丢失了~/.ssh
目录(带有原始的id_rsa
和id_rsa.pub
文件).
因此,我想直接在服务器上删除旧的SSH密钥,然后上传新的SSH密钥.
我尝试了以下命令,但没有成功:
$> ssh-add -D
有没有一种方法可以完全删除SSH密钥?
请注意,至少有两个关于ssh-add -d/-D
not 删除密钥的错误报告:
- " Debian错误报告#472477:
ssh-add -D
没有从gnome-keyring-daemon
内存" 中删除SSH密钥 - " Ubuntu:
ssh-add -D
删除所有身份不起作用.另外,为什么所有身份都会自动添加?"
确切的问题是:
更确切地说,关于这个问题:
- 它会浏览您的
.ssh
目录,并自动将找到的所有密钥添加到您的代理中. - 它不会让您删除那些键.
就在两天前(2014年8月21日),Ubuntu 14.04.4中仍然确认了此错误.
可能的解决方法:
- 导航到您的
~/.ssh
文件夹,然后将除要标识的密钥文件以外的所有密钥文件移动到一个单独的文件夹中,该文件夹称为backup.如有必要,您也可以打开海马并从那里删除密钥. - 现在,您应该可以进行
git push
了.
另一种解决方法:
此评论实际上建议:
Ryan Lue 添加了另一个有趣的极端案例:
I currently have an old SSH key uploaded on a 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 an SSH key?
Note that there are at least two bug reports for ssh-add -d/-D
not removing keys:
- "Debian Bug report #472477:
ssh-add -D
does not remove SSH key fromgnome-keyring-daemon
memory" - "Ubuntu:
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:
- And it paws through your
.ssh
directory, and automatically adds any keys it finds to your agent. - And it won't let you delete those keys.
This bug is still confirmed in Ubuntu 14.04.4, as recently as two days ago (August 21st, 2014)
A possible workaround:
- Navigate to your
~/.ssh
folder and move all your key files except the one you want to identify with into a separate folder called backup. If necessary you can also open seahorse and delete the keys from there. - Now you should be able to do
git push
without a problem.
Another workaround:
This comments actually suggests:
Ryan Lue adds another interesting corner case in the comments:
That is the case when the keygrip
has been added as in here.
这篇关于如何删除SSH密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!