关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

云服务器Git Pull/Git Push配置SSH代理

发布时间:2024/8/28 14:59:32
香港云服务器

当git pull或push时经常会遇到Could not read from remote repository的报错,尤其是在启用Clash等代理软件后

# git push

kex_exchange_identification: Connection closed by remote host

Connection closed by 20.205.243.166 port 22

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

此时我们可以通过配置SSH代理来保障网络通畅,添加~/.ssh/config文件,配置如下内容

# cat ~/.ssh/config

Host github.com

    User git

    Hostname github.com

    Port 22

    ProxyCommand nc -v -x localhost:7890 %h %p

ProxyCommand依赖nc,服务器上需要提前安装nc

# apt-get install ncat