LoginSignup
4
9

More than 5 years have passed since last update.

proxy経由で社内からgithubにアクセスする。

Last updated at Posted at 2013-04-08

タイトル通り、proxy経由で社内からgithubにアクセスする方法について適当にまとめておきます。

環境

  • Windows7 Professional 32bit
  • git version 1.8.1.msysgit.1

手順

  • 環境変数HOMEをちゃんと設定しておく。

set HOME=C:\Users\rbtnn

  • SSH Public キーの作成する。

ssh-keygen -t rsa -C "mail-address@gmail.com"

にて~/.ssh/id_rsa~/.ssh/id_rsa.pubができます。

  • GithubにSSH Public Keysを登録する。

id_rsa.pubの内容をgithubの「Account Settings」の「SSH Public Keys」に登録してください。

  • ~/.ssh/configに設定を記述する。
Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

proxy経由でなければ、ここまでの設定でGithubにアクセスできるはずです。
ここから先はproxy経由する場合に必須となる手順です。

  • ~/.ssh/configにSSHの設定を追記する。

私の場合は以下のような感じになりました。proxy_url:proxy_portの部分は環境に応じて書き換えてください。
他のサイトでは、connect.exeを手に入れるためにソースからコンパイルして手に入れているみたいだけど、msysGitには普通に入っていました。

ProxyCommand C:/Git/bin/connect.exe -H proxy_url:proxy_port %h %p

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  TCPKeepAlive yes
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa

Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

Host gist.github.com
  User git
  Port 22
  Hostname gist.github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

  • .git/configのurlをSSH仕様に変更する。

rbtnn/vimrc.gitの部分は環境に合わせて書き換えてください。

 [core]
         repositoryformatversion = 0
         filemode = false
         bare = false
         logallrefupdates = true
         symlinks = false
         ignorecase = true
         hideDotFiles = dotGitOnly
 [remote "origin"]
         fetch = +refs/heads/*:refs/remotes/origin/*
-        url = git://github.com/rbtnn/vimrc.git
+        url = ssh://git@ssh.github.com:443/rbtnn/vimrc.git

 [branch "master"]
     remote = origin
     merge = refs/heads/master

以上


参考

4
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
9