Github SSH 访问:权限被拒绝(公钥)

Github SSH access: Permission denied (publickey)

我最近通过 Cygwin 在 Win10 上设置了一个 git 存储库,现在我正试图让它跟踪 github 上的远程存储库。

问题是,在像这样添加遥控器之后:

 git remote add github-remote git@github.com:username/github-remote.git

我无法以任何可能的方式访问它(通过 'show' 推送、获取、显示附加信息)。我得到的是:

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

虽然我知道这个话题已经被讨论了很多,但我发现 none 的解决方案确实有帮助。这就是为什么我决定 post 再问一个问题。

这是我一步一步做的:

1) 生成了 pub-priv 密钥对:

ssh-keygen -t rsa -b 4096 -C "mymail@ex.com"

尝试使用两者 - id_rsa 文件的默认目录和自定义目录。结果相同。

2) 运行 ssh 代理(或检查它 运行,准确地说):

eval $(ssh-agent -s)

3) 将密钥添加到代理

ssh-add ~/.ssh/id_rsa

4) 将 id_rsa.pub 复制到 github

5) 检查连接设置是否正确

ssh -T git@github.com

...取得了

的有希望的结果

You've successfully authenticated, but GitHub does not provide shell access.

据我了解,此错误可能是由于 git 的地址未包含在 /.ssh/known_hosts 文件中所致。事情是(据我所知)它是自动插入的,例如使用 'ssh -T' 所以我也怀疑是这种情况。尽管也尝试过:

ssh-keyscan -t rsa github.com | ssh-keygen -lf -

另一个可能的问题可能是我的私钥访问权限对用户来说太广泛了,但我也检查过了。

综上所述,我不知道如何解决这个问题,所以我将不胜感激任何帮助。提前谢谢你。

As for git, I downloaded the .exe from git-scm.com/download/win. SSH on the other hand I had to install as a Cygwin's package, and it's Cygwin's mintty in which I run all of the commands...

混合使用 Cygwin 和 Git For Windows 可能是问题所在。虽然我确信有一种方法可以让它们发挥作用,但最简单的方法是坚持其中一个。

Git 因为 Windows 有它自己的 "Git Bash" shell 而且,我相信,ssh。用那个。

或者,如果您想坚持使用 Cygwin,get Git from from Cygwin 并使用它。

Running Git through Cygwin from Windows 也可能有用。