本文介绍了如何删除SSH密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在服务器上上传了旧的SSH密钥.问题是我丢失了~/.ssh目录(带有原始的id_rsaid_rsa.pub文件).

因此,我想直接在服务器上删除旧的SSH密钥,然后上传新的SSH密钥.

我尝试了以下命令,但没有成功:

$> ssh-add -D

有没有一种方法可以完全删除SSH密钥?

解决方案

请注意,至少有两个关于ssh-add -d/-D not 删除密钥的错误报告:

确切的问题是:


更确切地说,关于这个问题:

  • 它会浏览您的.ssh目录,并自动将找到的所有密钥添加到您的代理中.
  • 它不会让您删除那些键.

就在两天前(2014年8月21日),Ubuntu 14.04.4中仍然确认了此错误.


可能的解决方法:

  • 导航到您的~/.ssh文件夹,然后将除要标识的密钥文件以外的所有密钥文件移动到一个单独的文件夹中,该文件夹称为backup.如有必要,您也可以打开海马并从那里删除密钥.
  • 现在,您应该可以进行git push了.

另一种解决方法:

此评论实际上建议:


Ryan Lue 添加了另一个有趣的极端案例:

keygrip 已添加在此处.

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:

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密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 23:31