GitHub中配置ssh遇到的问题解决
来源:互联网 发布:java求两个时间差 秒 编辑:程序博客网 时间:2024/05/27 12:21
原文:http://blog.itpub.net/25851087/viewspace-1262468/
【问题发生环境和相关参数】
【问题发生环境和相关参数】
(1)OS:Win7 32Bit.
(2)Git:GitHub for Windows 2.0.
下载地址:https://windows.github.com/
(3)Command Shell:Git Shell.
【问题重现描述】
①利用命令“ssh-keygen -t rsa -C "zjrodger@163.com" 生成SSH密匙(id_rsa和id_rsa.pub)后,将本地的“id_rsa.pub”文件中的内容上传到Github上的个人“SSH Keys”管理项中,从而生成一个新的SSH Keys。
②之后,进行本地与Remote Server(Github网站)的连接测试,命令和结果如下所示:
F:\Workspaces\Github_Workspace> ssh -T git@github.com
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of know
n hosts.
Permission denied (publickey).
在Windows的PowerShell中输入“ssh -T git@github.com”,结果出现“Permission Denied(publickey)”Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of know
n hosts.
Permission denied (publickey).
【问题原因】
在Github for Windows 2.0默认的安装配置中,SSH的配置文件ssh_config中的“IdentityFile“
与实际情况不相符。
在Github for Windows 2.0上(默认安装情况下),SSH的配置文件ssh_config中的“IdentityFile(其值为密匙的全路径名)”这项信息的内容是“~/.ssh/github_rsa”,如下命令所示:
Host github.com
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
IdentityFile=~/.ssh/github_rsa
(2)实际的情形
而实际上,通过命令“ssh-keygen -t rsa -C "zjrodger@163.com”生成的新的SSH密匙的全路径名为:“~/.ssh/id_rsa”和“~/.ssh/id_rsa.pub”。
注意:~/.ssh/github_rsa 不等于 ~/.ssh/id_rsa
(3)结论
①Git默认安装情况下,ssh_config配置文件中的“IdentityFile”项的值:IdentityFile=~/.ssh/github_rsa②实际的IdentityFile的值:IdentityFile=~/.ssh/id_rsa
如上所述,Github for Windows 2.0在默认安装情况下,SSH的的配置文件ssh_config中的“IdentityFile”项的值与实际新创建的密匙全路径名不相符,结果导致本地的SSH工具无法找到到正确的密匙,进而无法同已经上传到Github密匙相匹配,结果就出现了“Permission denied (publickey)”这样的错误。
(4)补充
①SSH配置文件ssh_config在自己本地的路径:
C:\Users\Administrator\AppData\Local\GitHub\PortableGit_6d98349f44ba975cf6c762a720f8259a267ea445\etc\ssh
②密匙文件的存放路径:
C:\Users\Administrator\.ssh
③ssh_config的原文件(有误的版本):
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
Host github.com
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
IdentityFile=~/.ssh/github_rsa④重装Github for windows 2.0后的新发现(重要)。
为了确保正确性,自己将本机的Github for Window 2.0卸载并且重装了一遍,发现SSH的配置文件ssh_config中的“IdentityFile”依然是“~/.ssh/github_rsa”。
而重装后的密匙文件的存放路径(C:\Users\Administrator\.ssh)下,有四个密匙文件,分别是github_rsa和github_rsa.pub,id_rsa和id_rsa.pub,
这样,用户就不用自己新建密匙文件了,只用将“github_rsa.pub”中的内容上传到Github网站的个人SSH管理中即可。
之后,在本地与Remote端进行网络连通性测试,发现可以联通。
这样,考虑到修改软件原有配置信息所带来的隐患,笔者就不推荐自己手动修改SSH的配置文件ssh_config中的“IdentityFile”字段这个方法了。
【解决方法】
方法一:
方法二:
将新生成的密匙文件名字改为“github_rsa”,从而与ssh_config配置文件中的“IdentityFile”项的值相同。
方法三:
方法三:
重装Github for Window 2.0,不用新建密匙文件,而是用Github自带的“github_rsa.pub”文件。
总之,不论方法一,放法二还是方法三,一定要保持新生成的密匙文件的名字同“ssh_config”中“IdentityFile”字段的值一致即可。
【参考文档】
(1)原文链接:http://stackoverflow.com/questions/2127104/permission-denied-publickey-error-using-git-on-windows-7
If it says "Permission denied (publickey)" you will have to put in a passphrase for your key. Do not be tempted to just press enter...this was what worked for me...it took me five hours to realize that pressing enter made OpenSSH feel that your key was too public so that is why it is denying you from going to the next step.
(2)原文链接:http://stackoverflow.com/questions/17383177/permission-denied-publickey-errors-on-windows-when-using-moovweb
So as mentioned in prior answers, the Permission denied error in Windows is because you are trying to use a key other than id_rsa.
Windows lacks the bells and whistles that Linux and Mac have to try out all your public keys when trying to connect to a server via SSH. If you're using the ssh command, you can tell it which key to use by passing the -i flag followed by the path to the key to use:
F:\Workspaces\Github_Workspace> ssh -T git@github.com
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of know
n hosts.
Permission denied (publickey).
F:\Workspaces\Github_Workspace> ssh -i ~/.ssh/id_rsa git@github.com
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of know
n hosts.
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
Hi zjrodger! You've successfully authenticated, but GitHub does not provide shel
l access.
Connection to github.com closed.
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of know
n hosts.
Permission denied (publickey).
F:\Workspaces\Github_Workspace> ssh -i ~/.ssh/id_rsa git@github.com
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of know
n hosts.
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
Hi zjrodger! You've successfully authenticated, but GitHub does not provide shel
l access.
Connection to github.com closed.
0 0
- GitHub中配置ssh遇到的问题解决
- github中ssh配置
- github的SSH配置
- 配置github上的ssh
- GitHub的SSH提交配置
- Github SSH key 的配置
- SSH连接GitHub遇到的问题
- 关于在配置hibernate中遇到的问题解决方法
- DroidBox配置遇到的问题解决
- ssh无密码登陆配置以及yum安装之前遇到的问题解决
- Pycharm的git/github配置及其问题解决
- 工具使用之Github的SSH配置
- Windows下配置github的ssh
- windows下GitHub的SSH key配置
- Windows配置Github的SSH-key
- windows下GitHub的SSH key配置
- TortoiseGit配置GitHub账号的SSH keys
- gitHub:配置SSH连接GitHub
- 本人在安装oracle10g客户端程序的时候发生了错误
- Android中TableLayout中的布局
- zhphp framework (十四) widget 挂件
- 第一章 你的第一行代码
- mark--难舍GStc
- GitHub中配置ssh遇到的问题解决
- excel复制到plsql
- Windows 10_x64 PL/SQL 链接64位 Oracle
- Android 学习资源收集
- OC-028.ARC自动内存管理的自动释放池
- java嵌套类和内部类
- hadoop(1.1.2)+hbase0.98+hive+pig+sqoop+mysql+vsftp+tomcat+linux搭建命令
- zhphpframework (十五) 程序分发,静态反射调用
- centos7安装spice客户端