更新 2018 年 5 月 14 日我更新了我的操作系统并不得不重新启动我的机器,所以这显然搞乱了我对这个问题的修复,这似乎是暂时的。为了再次暂时解决这个问题,我必须执行以下操作:
- ran
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/your-ssh-key
- 输入您的 ssh 密钥密码
- 运行任何你想要的 git 命令
我需要考虑将其永久化。这肯定和我评论有关Host *
我的 .ssh/config 文件中的部分,所以我需要弄清楚如何对某些而不是所有主机使用钥匙串,因为所有主机都不适合我的设置。
2018 年 5 月 2 日更新:
如果有人遇到这个问题,我使用了输出ssh -vT [email protected] /cdn-cgi/l/email-protection
找到从哪里获取配置,这导致我做一些事情来解决我的问题:
- removed
name
来自我的价值.gitconfig
在我的根文件夹中找到~
- 如上所示,我的中有一个部分
.ssh/config
归档Host *
我注释掉了
- 证实
git config user.name
and git config user.email
已针对我正在处理的特定存储库正确设置
- 确认我的远程仓库设置正确,例如
git remote set-url origin git@github-newkeyname:repo_git_target
Thanks.
我有一个工作和个人 GitHub 帐户,最近想使用我的个人帐户工作。但是,我不断收到一条错误消息:
Permission to personalUserName/repoName.git denied to globalUserName
我查找了如何使用多个 GitHub 帐户并找到了这个教程 -https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574 https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574
我按照所有说明进行操作,最后使用新密钥添加了遥控器,如教程中所述,例如
git remote add origin git@github-newkeyname:username/repoName.git
当我尝试从本地项目推送到我的个人 GitHub 存储库时,出现以下错误:
ERROR: Permission to localUserName/repoName.git denied to globalUserName.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我在这里注意到的一件事是localUserName/repoName.git
包括我添加的本地用户名git config user.name
,并且错误显示添加的用户名(很久以前)的权限被拒绝git config --global user.name
.
我不确定问题是否与 SSH 密钥或 git 配置有关,或两者都有关。有没有人有什么建议?
当我测试 SSH 连接时ssh -vT git@github-newkeyname
and ssh -vT git@github
,我看到两者都使用相同的用户名进行身份验证,在本例中,我称之为 globalUserName,即
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi globalUserName! You've successfully authenticated, but GitHub does not provide shell access.
这是我的 SSH 配置文件在相关位置的样子:
94 Host *
95 UseKeychain yes
96 AddKeysToAgent yes
97 IdentityFile ~/.ssh/someFile.pem
98
99 Host github-newkeyname
100 Hostname github.com
101 User git
102 IdentityFile ~/.ssh/id_rsa_newkeyname
103 IdentitiesOnly yes