Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make git work to push commits to GitHub via tor?

Tags:

So, GitHub is now officially banned by Russian Government and Rospotrebnadzor. I used GitHub to create free software and share it, and it's important part of my life.

Today I've installed Tor on Arch Linux and now I'm able to browse GitHub and other banned sites. I tried to make git work via Tor but without success.

Here is what I did:

git config --global http.proxy localhost:9050 git config --global https.proxy localhost:9050 

But when I try to push, I get error 501:

fatal: unable to access 'https://[email protected]/X/X.git/': Received HTTP code 501 from proxy after CONNECT

So, 501 means 'not implemented'. I have little experience with Tor (but from now on I'm starting to appreciate it), so don't know if it's really impossible to use Tor this way or I'm doing something wrong.

Q: how to configure git to use it via Tor?

like image 725
Mark Karpov Avatar asked Dec 03 '14 18:12

Mark Karpov


People also ask

How do I push a git repository to GitHub?

At the top of your repository on GitHub.com's Quick Setup page, click to copy the remote repository URL. In the Command prompt, add the URL for the remote repository where your local repository will be pushed. Push the changes in your local repository to GitHub.com.

How do I push commits to remote repository?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.


2 Answers

Setting an HTTP or HTTPS proxy will not work, because Tor acts on port 9050 as a SOCKS proxy. What will work instead is the software socat with some settings inside your SSH config:

Host github   HostName github.com   IdentityFile /path/to/your/file   User git   ProxyCommand socat STDIO SOCKS4A:127.0.0.1:%h:%p,socksport=9050 

Your SSH settings usually live in ~/.ssh/config. The configurations above tell SSH settings for the host github. It takes your input and directs it via socat through Tor.

Now you can do a git COMMAND ssh://github/USER/REPO and git will do your COMMAND via Tor.

like image 121
qbi Avatar answered Oct 04 '22 20:10

qbi


It might be easier to install a VM as suggested, like Whonix (also on GitHub), which will:

  • take care of the Tor connection
  • allow you to use Git with GitHub without having to define any proxy.
like image 32
VonC Avatar answered Oct 04 '22 20:10

VonC