简体   繁体   English

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

[英]Github SSH access: Permission denied (publickey)

I've recently set up a git repository on Win10 via Cygwin and now I'm trying to make it track a remote repo on github. 我最近通过Cygwin在Win10上建立了一个git仓库,现在我试图使其在github上跟踪一个远程仓库。

The problem is, that after adding a remote like this: 问题是,在添加了这样的遥控器之后:

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

I cannot access it in any possible way (pushing, fetching, displaying additinal info by 'show'). 我无法以任何可能的方式访问它(按,显示,通过“显示”显示附加信息)。 All I get is this: 我所得到的是这样的:

git@github.com: Permission denied (publickey). git@github.com:权限被拒绝(公钥)。

fatal: Could not read from remote repository. 致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists. 请确保您具有正确的访问权限,并且存储库存在。

Although I know this topic's been discussed a lot, none of the solutions I found actually helped. 尽管我知道这个话题已经讨论了很多,但是我发现的解决方案都没有帮助。 That's why I decided to post yet another question. 这就是为什么我决定发布另一个问题。

Here's what I did, step-by-step: 这是我的逐步操作:

1) Generated the pub-priv keypair: 1)生成pub-priv密钥对:

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

Tried with both - a default and a custom directory for the id_rsa files. 尝试同时使用-id_rsa文件的默认目录和自定义目录。 Same results. 结果相同。

2) Ran the ssh agent (or checked for it running, to be precise): 2)运行ssh代理(或准确地说,检查它是否正在运行):

eval $(ssh-agent -s)

3) Added the key to the agent 3)将密钥添加到代理

ssh-add ~/.ssh/id_rsa

4) Copied the id_rsa.pub to github 4)将id_rsa.pub复制到github

5) Checked if the connection's set properly 5)检查连接设置是否正确

ssh -T git@github.com

... with a promising result of ...具有令人鼓舞的结果

You've successfully authenticated, but GitHub does not provide shell access. 您已成功通过身份验证,但是GitHub不提供Shell访问。

From what I learned this error may be due to git's address not being included in the /.ssh/known_hosts file. 据我了解,此错误可能是由于git的地址未包含在/.ssh/known_hosts文件中。 The thing is (as far as I know) that it is being inserted automatically eg with 'ssh -T' so I doubt it's the case, either. 事情是(据我所知)它是自动插入的,例如用'ssh -T',所以我怀疑是这样。 Although tried that as well: 虽然也尝试过:

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

Another possible problem could be my private key's access being available too widely for the users, but I checked that, too. 另一个可能的问题可能是我的私钥访问权限对于用户而言过于广泛,但我也对此进行了检查。

With all that said I have no further idea how to fix this one, so I'd appreciate any help. 综上所述,我不知道如何解决此问题,因此,我将不胜感激。 Thank you in advance. 先感谢您。

As for git, I downloaded the .exe from git-scm.com/download/win. 至于git,我从git-scm.com/download/win下载了.exe。 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... 另一方面,SSH我必须作为Cygwin的软件包安装,这是Cygwin的薄荷,在其中运行所有命令...

Mixing Cygwin and Git For Windows is likely the problem. 将Cygwin和Git For Windows混合使用可能是问题所在。 While I'm sure there's a way to make them work, it's simplest to stick to one or the other. 虽然我敢肯定有一种方法可以使它们正常工作,但最简单的方法就是坚持一个或另一个。

Git For Windows comes with its own "Git Bash" shell and, I believe, ssh. Git For Windows带有自己的“ Git Bash”外壳,并且我相信它是ssh。 Use that. 用那个

Or, if you want to stick with Cygwin, get Git from from Cygwin and use that. 或者,如果您想坚持使用Cygwin,请从Cygwin获得Git并使用它。

Running Git through Cygwin from Windows might also be useful. 从Windows通过Cygwin运行Git也可能有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM