sqlo 发表于 2015-12-13 10:32:55

ubuntu git http proxy配置

有些公司上网会有统一的http proxy服务器,一般公司会给你http的代理配置,这样你就可以通过http协议上网了,如果git server提供了http访问的方式,是没有问题的,但是如果git server只提供ssh访问,此时,就不能进行git 操作了,需要做一些配置才行。

1. 安装socat
    sudo apt-get install socat
2. 编写配置文件gitproxy
(1)找到socat的安装目录,通常才/usr/bin,并在此目录下创建gitproxy文件,文件内容如下:




[*]#!/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 gitproxy
[*]# git config --global core.gitproxy gitproxy
[*]#
[*]# More details at http://tinyurl.com/8xvpny
[*]
[*]# Configuration. Common proxy ports are 3128, 8123, 8000.
[*]_proxy=proxy.yourcompany.com#贵公司的代理服务器地址
[*]_proxyport=3128               #端口
[*]
[*]exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
(2)增加gitproxy可执行权限
   sudo chmod a+x gitproxy
(3)配置git的全局代理
      git config --global core.gitporxy gitproxy

经过以上步骤,就可以执行git clone操作了。
页: [1]
查看完整版本: ubuntu git http proxy配置