SSH已添加,但仍然致命无法从远程存储库中读取

时间:2017-03-19 19:28:09

标签: linux git github ssh

当我执行以下操作时:

$ 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

我错过了一步吗?我可以尝试的其他任何故障排除步骤建议?

2 个答案:

答案 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帐户未显示任何存储库。

  1. 存储库实际上是否存在? (只需在浏览器中打开它。例如,ssh://github.com/ConfusedDeer/myiOSapp.git打开http://github.com/ConfusedDeer/myiOSapp
  2. 尝试新的克隆:git clone ssh://github.com/ConfusedDeer/myiOSapp.git并查看是否有效