当前位置:   article > 正文

github ssh被屏蔽的解决方案_github ssh突然连不上了

github ssh突然连不上了

发现今天开始github的ssh都被屏蔽了,导致git命令没法用,之前只是屏蔽了https而已,唉。

检查是否有安装connect

$bash: connect
connect --- simple relaying command via proxy.
Version 1.101
usage: connect [-dnhst45] [-p local-port][-R resolve] [-w timeout]
          [-H proxy-server[:port]] [-S [user@]socks-server[:port]]
          [-T proxy-server[:port]]
          [-c telnet-proxy-command]
          host port
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

如提示没有则进行安装

sudo apt update -y
sudo apt install connect-proxy
  • 1
  • 2

如果update后install还是提示找不到connect-proxy包,检查系统软件源

vim /etc/apt/sources.list
  • 1

若没有可使用清华或阿里云之类的镜像,复制内容写入即可
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

创建ssh配置文件

vim ~/.ssh/config
  • 1

配置文件中写入以下内容,ProxyCommand 中的代理地址 localhost:1080 根据实际情况修改

Host github.com
        User xxx@email.com
        Port 22
        HostName github.com
        IdentityFile "~/.ssh/id_rsa"
        TCPKeepAlive yes
        ProxyCommand connect -S localhost:1080 -a none %h %p

Host ssh.github.com
        User xxx@email.com
        Port 443
        HostName ssh.github.com
        IdentityFile "~/.ssh/id_rsa"
        TCPKeepAlive yes
        ProxyCommand connect -S localhost:1080 -a none %h %p
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

开启代理,git pull一下,完毕。

windows用户的IdentityFile可能位于 C:/Users/<用户名>/.ssh/id_rsa

wsl2用户可以用cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " "获取windows主机ip配置代理。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/45055
推荐阅读
相关标签
  

闽ICP备14008679号