背景:电脑(win10)重装后,提交(push)代码提示ssh: connect to host github.com port 22: Connection refused,无法进行代码提交。
在windows上更新了git仓库中的代码后,由于我前阵子刚重装了系统,ssh key都是重新生成的,而且我本机上有一个gitlab账号,有一个github账号,都放在~/.ssh目录下,具体文件如下:
上图中的iwwenbo_rsa.pub就是我github账户的公钥,然后就是我提交代码时候的报错信息如下:
$ git push origin master
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决上述问题的方法是更改~/.ssh/config文件,将github.com的HostName更改为下列内容,并指定端口,内容如下:
#default gitlab
Host gitlab
HostName gitlab
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host github.com
HostName ssh.github.com
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/iwwenbo_rsa
==============2016年7月26日更新================
后来发现,我这里无法进行连接的原因竟是我在hosts文件里加的github的ip无法访问了,我就把hosts文件里关于github的ip全部删掉了,然后更改~/.ssh/config文件为下列内容(我有一个gitlab账号,一个github账号):
#default gitlab
Host gitlab
HostName gitlab
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/iwwenbo_rsa
然后使用如下命令进行ssh测试,根据提示把主机添加到~/.ssh/known_hosts文件中,然后就正常了:
$ ssh -T [email protected]
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi iwwenbo! You've successfully authenticated, but GitHub does not provide shell access.
内容参考:Github (SSH) via public WIFI, port 22 blocked.
最新评论
网飞没问题, 迪士尼+有解决方案么?
pp助手是安卓手机用的,根本下载用不来苹果
已解决
这样的话数据库里的结构为{"attachment":{"content":"xxx"}}, 要怎么才能变成{"content":"xxx"},从而使结构保持一致?
赞! make test不过的坑都写到的,谢谢楼主~
谢谢你
用了root用户还是一直502是怎么回事呢
student id 是空的