ssh: connect to host github.com port 22: Connection timed out


今天在使用github上遇到一个错误


ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.


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


开始以为是网络有问题,github不能够连接上,但是使用ssh命令, 用端口443测试发现可以连接上github


 ssh -T -p 443 git@ssh.github.com
Enter passphrase for key '/root/.ssh/id_rsa': 
Hi zhikunhuo! You've successfully authenticated, but GitHub does not provide shell access.


于是就怀疑端口22不能使用,端口22为ssh默认端口,初步怀疑与github服务器有关,于是将其端口修改为443:

修改方法

:/repo# cd ~/.ssh/

进入到~目录下面的.ssh下面,修改ssh配置,新建config文件

将上述文件添加配置:

Host github.com    /*服务器地址为github地址*/

User "XXX@XX.com"  /*github上的注册邮箱 为用户账号*/

Hostname ssh.github.com   /*服务器地址为github地址*/

PreferredAuthentications publickey  /*采用公匙*/

IdentityFile ~/.ssh/id_rsa    /*公匙文件路径*/

Port 443                           /*修改端口为443*/



保持配置,重新git clone

:/repo# git clone git@github.com:zhikunhuo/training.git
Cloning into 'training'...
Enter passphrase for key '/root/.ssh/id_rsa': 
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (5/5), 12.32 KiB | 0 bytes/s, done.
Checking connectivity... done.


OK   完美解决。



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值