简体   繁体   English

Git:权限被拒绝

[英]Git: Permission Denied

I am trying to set up git as a first time user and proceeded as in the following tutorials: 我正在尝试将git设置为首次使用,并按照以下教程进行操作:

Setting up git 设置git

and now I am stuck at step 5 so i tried the SSH issues at github SSH issues . 现在我陷入了第5步,所以我在github SSH issue上尝试了SSH问题 I have generated all the keys and are placed in C:\\Users\\Admin.ssh as 我已经生成了所有密钥,并将它们放置在C:\\ Users \\ Admin.ssh中, 文件布局 Upon trying for 在尝试

ssh -vT github.com 

I am getting Permission denied error though I have pasted the id_dsa at github. 尽管我已将id_dsa粘贴在github上,但出现了“权限被拒绝”错误。 I have disabled the firewall(was blocking port 22 earlier) and edited config as: 我已禁用防火墙(之前已阻止端口22),并将配置编辑为:

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile C:\Users\Admin\.ssh\id_dsa
Port 443 

在此处输入图片说明

What wrong am i doing here?? 我在这里做什么错?

You should SSH to git@github.com . 您应该SSH到git@github.com Ie, the username for SSH is always git , not your GitHub username. 即,SSH的用户名始终是git而不是您的GitHub用户名。

You also should have pasted id_dsa.pub into GitHub. 您还应该将id_dsa.pub粘贴到GitHub中。 You should really generate new keys, since now your private key has been compromised. 您确实应该生成新密钥,因为现在您的私钥已被破坏。

You're using the wrong file, you need to upload the public key, which ends in .pub . 您使用了错误的文件,您需要上传以.pub结尾的公共密钥。 Since Windows is hiding the file extensions by default, you can tell which is the .pub file because Windows is claiming it's a "Microsoft Office P..." filetype (I assume Publisher). 由于Windows默认情况下隐藏文件扩展名,因此您可以分辨出哪个是.pub文件,因为Windows声称它是“ Microsoft Office P ...”文件类型(我假设是Publisher)。

Open the file in a text editor such as Notepad, and then copy that data to GitHub. 在文本编辑器 (如记事本)中打开文件,然后将该数据复制到GitHub。 The other is your private key which you should never share with anyone else. 另一个是您的私钥 ,您绝对不应与他人共享。

Disclaimer: I have never used github, all my knowledge comes from using a git I set up on my own NAS. 免责声明:我从未使用过github,我的全部知识都来自于使用在自己的NAS上设置的git。

I might be wrong, but from what I am reading, you are trying to authenticate using the file you pasted into github. 我可能是错的,但是从我阅读的内容来看,您正在尝试使用粘贴到github中的文件进行身份验证。 This is wrong, because you have one public and one private part of your keypair. 这是错误的,因为您的密钥对只有一个公共部分和一个私有部分。 You paste the public part into github und authenticate using the private part. 您将公共部分粘贴到github中,然后使用私有部分进行身份验证。

dsa and rsa are, as far as I remember, different algorithms used to generate keypairs. 据我所知,dsa和rsa是用于生成密钥对的不同算法。

For username issues, the next answer sais it has to be git , not your own username. 对于用户名问题,下一个答案是必须是git而不是您自己的用户名。

In your C:\\Users\\someuser.shh\\ dir there should be only one id_rsa and id_rsa.pub. 在C:\\ Users \\ someuser.shh \\目录中,应该只有一个id_rsa和id_rsa.pub。 The .pub key is the one you upload to github. .pub密钥是您上传到github的密钥。

What I would do, assuming github is the only git server you are connecting to, is delete all o the id_rsa files and start over with a fresh set using: 假设github是您要连接的唯一git服务器,我要做的就是删除所有id_rsa文件,并使用以下命令重新设置一个新的设置:

ssh-keygen -t rsa -C "your_email@youremail.com"

accept the default name. 接受默认名称。

The config file is used to identify the check in but the emails should match what you intend to use. 配置文件用于标识签入,但电子邮件应与您打算使用的匹配。

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

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