23

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://X@github.com/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?

Mark Karpov
  • 7,499
  • 2
  • 27
  • 62
  • 1
    Related: http://stackoverflow.com/questions/10274879/how-to-contribute-on-github-anonymously-via-tor – raina77ow Dec 03 '14 at 18:56
  • Also related: http://stackoverflow.com/questions/783811/getting-git-to-work-with-a-proxy-server And, as CQM suggested in the post linked by raina, it might be easier to just set up a VM whose only internet connection is through Tor. It might work without needing to proxy then. – Eric Palace Dec 03 '14 at 20:06
  • For web browsing Hola plugin for chrome is a simpler and faster solution then tor. https://chrome.google.com/webstore/detail/hola-better-internet/gkojfkhlekighikafcpjkiklfbnlmeio?hl=en – xvorsx Dec 13 '14 at 02:59
  • 1
    @xvorsx, well, Tor also gives you privacy if you follow some rules. As far as I know Google Chrome is proprietary software. How can you believe you have privacy when you use proprietary software? I don't use Google Chrome because it would be the only software on my system that is not free (in terms of license). – Mark Karpov Dec 14 '14 at 12:52
  • Possible duplicate of [Using a socks proxy with git for the http transport](http://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport) – user Mar 30 '17 at 12:19
  • Possible duplicate of [How to contribute on github anonymously via Tor?](http://stackoverflow.com/questions/10274879/how-to-contribute-on-github-anonymously-via-tor) – Ciro Santilli OurBigBook.com May 13 '17 at 19:50

6 Answers6

22

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.

qbi
  • 2,104
  • 1
  • 23
  • 35
  • 1
    Nice solution, perhaps worth noting that the usual location of `IdentityFile` is `~/.ssh/id_rsa`. I actually did the same with Heroku. With Heroku you just need to create git remotes (`--ssh-git` passed to `heroku create`) as their default Git transport is thru http. – MatzFan Apr 05 '19 at 22:44
4

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.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
4

You used a wrong syntax, correct is:

git config http.proxy socks5://localhost:9150 # 9150 for TOR browser, 9050 for TOR service git config https.proxy socks5://localhost:9150

Drakmail
  • 682
  • 2
  • 7
  • 22
1

You could switch from httpsto sshand use the tor SOCKS proxy in this way:

export SOCKS_SERVER=localhost:9050
git clone ssh://github.com/user/repo

Note that you need credentials when using ssh!

Eun
  • 4,146
  • 5
  • 30
  • 51
1

Take a look at Tails OS and PIA. Both of these should keep you safe and free.

Brian
  • 2,494
  • 1
  • 16
  • 21
1

You can use a tool like proxychains to proxy a TCP connection via a socks5 server, that is a Tor daemon.

You've to install proxychains, on Debian based distros, you can do so with
$ sudo apt install proxychains and you can look it up for installing on your specific distro.

Once you installed it, the default configuration file is located at /etc/proxychains.conf, you've to change the last line from socks4 127.0.0.1 9050 to socks5 127.0.0.1 9050, this is not required but if you'd like to use socks5 features like stream isolation and such, it's needed.

And now, you can just do $ proxychains git clone https://github.com/repo or any git operation, and all these connections will go through the local socks5 server.

Harsath
  • 133
  • 3
  • 6