Thursday, July 1, 2021

Git clone over ssh socks proxy

This is useful for a machine that needs to clone some repository from github, but does not having internet connection.

First, we must identify another machine that can access, we can call this server proxy-server.

Then, establish a socks proxy from our no-internet-server
$ ssh -qN -D 1234 proxy-server

The above command will create a socks proxy at localhost port 1234

Use the git command with socks proxy. Let's say we want to clone the 30-seconds-of-code repository, run below command in a new shell
$ git -c http-proxy=socks5h://localhost:1234 clone

Once done, press ctrl-c in the first shell, to terminate the socks proxy

No comments: