Ubuntu Linux下通过代理(proxy)使用git上github.com

配制过程分为以下几步:

1. 安装socat,在ubuntu下使用以下命令安装


sudo apt-get install socat

2. 编辑一个脚本文件,名字为git-proxy ,内容如下

#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path
# (e.g., ~/bin) and then run
# chmod +x git-proxy
# git config --global core.gitproxy git-proxy
#
#
# Configuration. Common proxy ports are 3128, 8123, 8000.
_proxy= 172.26.100.238
_proxyport=64000
exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport

 3. 将git-proxy放到一个目录下,如我将它放到/home/wilsonke/local/bin,并将该目录加入到PATH

cp git-proxy /home/wilsonke/local/bin/

将该目录加入到PATH,加入以下内容到~/.bashrc,然后souce ~/.bashrc

export PATH=$PATH:/home/wilsonke/local/bin

source ~/.bashrc

4. 修改~/.gitconfig,加入以下行和代理

[push]
	default = simple
[user]
	name = wilsonke77
	email = 275156430@qq.com
[core]
	editor = emacs
	gitproxy = git-proxy
[https]
	proxy = http://wilson_ke:password@172.26.100.238:64000
[http]
	proxy = http://wilson_ke:password@172.26.100.238:64000

5. 下载转换协议文件connect.c,下载地址 点击

gcc -o connect connect.c

将编译后的文件connect也拷贝到/home/wilsonke/local/bin下


6. 修改~/.ssh/config,加入以下行

ProxyCommand /home/wilsonke/local/bin/connect -H 172.26.100.238:64000 %h %p
Host github.com
User 275156430@qq.com
Port 443
Hostname ssh.github.com

7.完成并测试

git clone https://github.com/facebook/wangle

如果能正常clone下来,则表示成功。


后记:很多开源项目同时可能还会用到wget来下载代码,同样,wget也要设置代理服务器


创建用户的~/.wgetrc文件中,添加如下内容:

http_proxy = http://172.26.100.238:64000/
ftp_proxy = http://172.26.100.238:64000/
--proxy-user=wilson_ke
--proxy-passwd=password

完成了上述配置后,就可以成功编译facebook的项目proxygen


参考资料

http://blog.csdn.net/loveaborn/article/details/24575659

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值