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

在遵循廖雪峰Git教程使用SSH方式添加远程库并尝试推送时遇到错误,提示主机认证无法建立及连接被阻止。解决方案是删除SSH关联,改用HTTPS方式关联并成功推送。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

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

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

后,使用推送文件命令:

$ 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.

错误如图:

尝试删除known_hosts文件,无果

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

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

解决

先删除原来ssh方式关联

$ git remote rm origin

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

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

推送

$ git push -u origin master

完成推送。

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

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

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值