ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

在操作廖雪峰Git教程添加远程库时,按步骤添加ssh key后推送出错。

在ssh方式下关联本地git版本库和github版本库:

$ git remote add origin [email protected]:Yikoufang/gitlearning.git

其中Yikoufang:本人的用户名,gitlearning:自己创建的库名

ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

后,使用推送文件命令:

$ git push -u origin master

出错如下:

The authenticity of host 'github.com (13.250.177.223)' can't be established.
RSA key fingerprint is SHA256:3fgcj8jD9wTZJFlcOjIZyO4PH/KlJJ5JvF4Ghw5BGLU.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts.
Received disconnect from 13.250.177.223 port 22:2: Connection blocked because server only allows public key authentication. Please contact your network administrator.
Disconnected from 13.250.177.223 port 22
fatal: Could not read from remote repository.

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

错误如图:
ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

尝试删除known_hosts文件,无果

百度,stack overflow,完全搜不到相同问题,耗时一天,[/狗头]。

唯一搜到一个相同,没有解决方法,下面评论有人也出现了这个问题,于是尝试改用HTTPS方式关联库,结果就可以完成上传推送。

解决

先删除原来ssh方式关联

$ git remote rm origin

ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

改用HTTPS方式关联git本地版本库和github库

$ git remote add origin https://github.com/Yikoufang/gitlearning.git

ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

推送

$ git push -u origin master

ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

完成推送。

https方式上传文件到GitHub参考:https://blog.****.net/geerniya/article/details/79552247

廖雪峰git教程-从远程库克隆原文

ssh方式下:git push -u origin master出错Received disconnect from 13.250.177.xxx port 22

好吧,是我没看到,看来是公司不让用ssh协议。