2011年7月20日水曜日

認証付きproxy越にgit cloneをする

社内からgit cloneをするとき、認証付きのproxyが邪魔をして繋げない。
素でやると、
$ git clone https://github.com/xxx/yyy.git zzz
Cloning into zzz...
error: The requested URL returned error: 403 while accessing https://github.com/xxx/yyy.git/info/refs

fatal: HTTP request failed
エラー。
環境変数 http_proxy を設定してみると、
$ export http_proxy=http://proxy:port
$ git clone https://github.com/xxx/yyy.git zzz
Cloning into zzz...
error: The requested URL returned error: 403 while accessing https://github.com/xxx/yyy.git/info/refs

fatal: HTTP request failed
変化無し。
検索すると、トンネリングツールのCorkscrewを使って対応している記事が多数見つかる。
見様見真似で試してみる。
$ sudo apt-get install corkscrew
# ラッパースクリプト作成

$ cat << EOF > /path/to/bin/git-proxy
#!/usr/bin/env bash
# -*- mode:sh; coding:utf-8 -*-

PROXY_HOST=http://server
PROXY_POST=8080
CORKSCREW=/usr/bin/corkscrew

$CORKSCREW $PROXY_HOST $PROXY_POST $1 $2

EOF
# .bashrcに環境変数追加
export GIT_PROXY_COMMAND=/path/to/bin/git-proxy

$ git clone https://github.com/xxx/yyy.git zzz

Cloning into zzz...
error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://github.com/xxx/yyy.git/info/refs

fatal: HTTP request failed
進展有り。
CA verificationを無効にすればOKらしい。> 参照
$ git config --global --add http.sslVerify false
$ git clone https://github.com/xxx/yyy.git zzz
Cloning into zzz...
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 197 (delta 104), reused 177 (delta 89)
Receiving objects: 100% (197/197), 26.51 KiB, done.
Resolving deltas: 100% (104/104), done.
成功!
上のコマンドで ~/.gitconfig に以下が追加された。
[http]
sslVerify = false

0 件のコメント:

コメントを投稿