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

yhqotfr8  于 2023-04-28  发布在  Git
关注(0)|答案(4)|浏览(622)

嗨,我最近买了一台二手Mac用于开发,但是当我试图将代码从我的Mac推送到我的Github存储库时。我会得到这个错误:Permission to myself/testuser。git denied to oldmacowner例如。
我不知道该怎么办。我想我需要删除属于oldmacuser的旧ssh密钥,并从github设置新的ssh密钥。有人知道怎么做吗?谢谢。

zyfwsgd6

zyfwsgd61#

我必须做的是-
开放终端

cd ~/.ssh
open .

然后在finder中打开文件夹,然后删除id_***。pub(SSH密钥文件)。然后按照以下指示-

  • 在Finder中,搜索Keychain Access应用程序。
  • 在Keychain Access中,搜索github。com的网站上。
  • Keychain中的GitHub密码输入找到github的“internet password”条目。com的网站上。
  • 相应地编辑或删除条目。

https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
希望有帮助!

qhhrdooz

qhhrdooz2#

通常在OS X中ssh密钥存储在:

~/.ssh

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

rm keyname_rsa
ogq8wdun

ogq8wdun3#

  • 您应该更改git的全局配置。
  • $ git config --global user.name "Your Name"
  • $ git config --global user.email youremail@example.com
  • 在你的github账户中添加ssh key。
  • 复制并粘贴此cat .ssh/id_rsa.pub的输出

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

r55awzrz

r55awzrz4#

你需要做几件事:
1.检查Keychain Access应用程序中的SSH密钥并将其删除。如果用户运行过ssh-add --apple-use-keychain ~/.ssh/id_private_key,这些键将位于“本地项目”下
1.确保GitHub settings中的主电子邮件与您的本地git配置相匹配-您在git config --global user.email 'your.email@domain.com'中使用的配置
我建议在2之前重命名您的本地GitHub SSH密钥。

相关问题