A. you are on a firewalled network, from where you can’t access github (remote port:9418 is not allowed)
B. you want to access a securized git server from home, but your IP is not on the git server’s whitelist.
and, of course, you have ssh access on a server that can do this.
A. Make a ssh tunnel to the git server
Me –> ServerWithSSHAccess –> GitServer
The comand to use is:
:22 -N ,
where 2000 is the local port you will connect to, and 22 is the remote port used to connect to the git server (if the connection uses git:// instead of default ssh port, change this to 9418). Then, instead of:
git clone GitServer/my_repo,
you must use:
git clone localhost:2000/my_repo
B. Automatically use tunnel to connect to git server
Furthermore, if the repository is already cloned on your computer, or you want to use the same addresses, you can config your ssh client to automatically pick the tunneled connection when connecting to the git server. In ~/.ssh/config, add:
so now you can access your git repo as you were directly connected to it:
git clone GitServer/my_repo