git github 如何在我的 mac 上删除旧的 ssh 密钥?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37691375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:14:47  来源:igfitidea点击:

github how to delete old ssh key on my mac?

gitmacosgithubversion-controlssh-keys

提问by Benjamin Zheng

Hi I recently purchased a used mac for development, however when I try to push code from my mac to my github repository. I will be getting this error:Permission to myself/testuser.git denied to oldmacowner for example.

嗨,我最近购买了一台二手 mac 用于开发,但是当我尝试将代码从我的 mac 推送到我的 github 存储库时。我将收到此错误:例如,对自己/testuser.git 的权限被拒绝给 oldmacowner。

I am wondering how to go about this. I think I need to delete the old ssh key that belongs to the oldmacuser and set up a new ssh key from github. Anyone have an idea of how to go about it? Thanks.

我想知道如何解决这个问题。我想我需要删除属于 oldmacuser 的旧 ssh 密钥并从 github 设置一个新的 ssh 密钥。任何人都知道如何去做?谢谢。

回答by HADI

What i had to do is -

我必须做的是——

Open terminal

打开终端

cd ~/.ssh
open .

Then folder opened in finder then i removed id_***.pub (SSH key files). Then followed following instructions -

然后在finder中打开文件夹,然后我删除了id_***.pub(SSH密钥文件)。然后按照以下说明进行操作 -

Hope that helps!

希望有帮助!

回答by l'L'l

Usually in OS Xssh keys are stored in:

通常在OS Xssh 中密钥存储在:

~/.ssh

If you need to remove one of them:

如果您需要删除其中之一:

rm keyname_rsa

回答by Shravan40

  • You should change the global configuration of git.
  • $ git config --global user.name "Your Name"
  • $ git config --global user.email [email protected]
  • Add the ssh key of into your github account.
  • Copy and paste the output of this cat .ssh/id_rsa.pub
  • 您应该更改 git 的全局配置。
  • $ git config --global user.name "Your Name"
  • $ git config --global user.email [email protected]
  • 将 的 ssh 密钥添加到您的 github 帐户中。
  • 复制并粘贴此输出 cat .ssh/id_rsa.pub

P.S : I am assuming the public keys are stored into id_rsa.pub

PS:我假设公钥存储在 id_rsa.pub