使用git协议-通过socks5代理加速对github的访问

栏目: 编程工具 · 发布时间: 6年前

内容简介:github访问不流畅,影响工作效率。这里总结下如何通过工作原理 执行从错误的信息可以看出连接失败。

github访问不流畅,影响工作效率。这里总结下如何通过 socks 代理加速对github 的访问 。这使用 git 协议 ,因为使用 git协议可以看到网速,并且提交也很方便。 https协议似乎看不到clone的网速。首先要建立好socks5连接 。需要注意的地方就是填写自己的 sslocal 的参数信息

工作原理 执行 git clone git@github.com... 的时候,通过配置文件 ~/.ssh/config 浏览转发到 127.0.0.1:1080 然后交给 socks代理 进行处理。

yum -y install epel-release
yum -y install git tmux connect-proxy

type pip &> /dev/null

if [ $? -eq 1 ] ; then
        yum -y install python-pip
fi

pip install shadowsocks

sslocal  -s xxx.xxx.xxx.xxx -p xxxx -k 'xxxx' -m 'xxxx' -l 1080 -t 300  -l 1080 -d start

cat > ~/.ssh/config <<EOF
Host github.com
ProxyCommand connect-proxy -S 127.0.0.1:1080 %h %p
HostName %h
Port 22
User git
IdentityFile  ~/.ssh/id_rsa
IdentitiesOnly yes
EOF

测试连接

ssh -T git@github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

关闭 sslocal

yum -y install psmisc
killall sslocal
ssh -T git@github.com

FATAL: Unable to connect to relay host, errno=111
ssh_exchange_identification: Connection closed by remote host

从错误的信息可以看出连接失败。 ~/.ssh/config 把流量转移到了 127.0.0.1:1080 , 之后因为 关闭了 sslocal 就结束了。

停止 ssh 流量的转移

echo >  ~/.ssh/config

 ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address 'xx.xx.xx.xx' to the list of known hosts.
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

一个警告信息,还是提示成功了。这个是直接访问 github.com ,没有使用代理。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

亮剑.NET

亮剑.NET

2009-3 / 55.00元

《亮剑.NET:SharePoint Server 2007开发实战》共分为8章,详细讲解了SharePoint上常见的开发任务,讲述了各种开发场景下需要了解的知识,并提供了丰富的实例。《亮剑.NET:SharePoint Server 2007开发实战》第1章为基础知识,讲述SharePoint的基本概念,基本的对象模型,代码编写注意事项,并讲解了一个集开发和部署打包为一体的项目结构的创建;第2......一起来看看 《亮剑.NET》 这本书的介绍吧!

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具