Created
May 1, 2013 16:13
-
-
Save lynus/5496270 to your computer and use it in GitHub Desktop.
Using github through ssh tunnel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repo所在的机器A不能访问外网,可以通过中间机器B使用github(clone,push,pull) | |
1.建立A到B的ssh 隧道。 | |
2.分别修改~/.ssh/config 与 repo下面的 .git/config 文件 | |
参考http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/ 这篇文档。 | |
使用文档中图4的‘多主机转发应用‘ 方法。建立 A到B的通道: | |
ssh -g -L 7001:github.com:22 middle-host | |
其中middle-host 为中间机器B。通道建立好后,A机器将本机7001的连接转到B机器上。 | |
修改 ~/.ssh/config 文件,增加一下三行: | |
host localhost | |
hostname localhost | |
port 7001 | |
修改 .git/config 文件,将url改为指向localhost | |
类似于: | |
url = git@localhost:lynus/stochastic_computing.git | |
测试: | |
ssh git@localhost | |
若显示 ...You've successfully authenticated...文字,则隧道建立成功。之后使用git操作与平常操作无异。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment