当我执行以下操作时:
$ git pull origin master
它返回:
Permission denied (publickey).
fatal: Could not read from remote repository.
根据GitHub指示,我已经验证了以下内容:
1)使用以下命令创建密钥:
ssh-keygen -t rsa -b 4096 -C "myemail@gmail.com"
并将其命名为GitHub
返回:
Your identification has been saved in GitHub.
Your public key has been saved in GitHub.pub.
2)在.ssh目录和本地仓库位置添加到我的SSH代理:
eval "$(ssh-agent -s)"
和
ssh-add -K ~/.ssh/GitHub
返回:
Identity added: /Users/myUserName/.ssh/GitHub (/Users/myUserName/.ssh/GitHub)
3)使用pbcopy < ~/.ssh/GitHub.pub
复制密钥
并将密钥粘贴到GitHub设置页面中的相应设置区域。
4)从我当地的回购地点,我做ssh -T git@github.com
并返回:
Hi ConfusedDeer! You've successfully authenticated, but GitHub does not provide shell access.
5)我还做ssh-add -l
验证它已添加到我的ssh代理中并返回:4096 SHA256:PcgDpZHUEepM/cQvVn525I5fgwCgVj98wEloWiosQ4s /Users/myUserName/.ssh/GitHub (RSA)
6)我做了git remote -v
来验证原点位置是否正确并返回:
origin ssh://github.com/ConfusedDeer/myiOSapp.git (fetch)
origin ssh://github.com/ConfusedDeer/myiOSapp.git (push)
我将它们与我的GitHub帐户进行比较,看起来很好:git@github.com:ConfusedDeer/myiOSapp.git
7)我注意到设置界面上新添加的GitHub键是黑色的,但在我完成ssh -T git@github.com
之后它现在变为绿色,并指出:Added on Mar 19, 2017 Last used within the last day
我错过了一步吗?我可以尝试的其他任何故障排除步骤建议?
答案 0 :(得分:2)
问题是我需要将我的远程URL从HTTPS切换到SSH:我找到了instructions on GitHub。
我需要改变
发件人:强>
origin ssh://github.com/ConfusedDeer/myiOSapp.git (fetch)
origin ssh://github.com/ConfusedDeer/myiOSapp.git (push)
以强>
origin git@github.com:ConfusedDeer/myiOSapp.git (fetch)
origin git@github.com:ConfusedDeer/myiOSapp.git (push)
执行以下命令:
git remote set-url origin git@github.com:ConfusedDeer/myiOSapp.git
答案 1 :(得分:0)
您的github帐户未显示任何存储库。
ssh://github.com/ConfusedDeer/myiOSapp.git
打开http://github.com/ConfusedDeer/myiOSapp
)git clone ssh://github.com/ConfusedDeer/myiOSapp.git
并查看是否有效