I have recently set up an onion hidden service specifically to use it with git. I've used the method described in the answer for this question, however, I wasn't able to figure out the exact way to connect to the server, since neither ssh, nor git seem to support onion link format. Is there a way to connect to the git remote over tor?

Note: Onion service itself is functional. Tor Browser has no issues connecting to the server. However, git and ssh return errors like:

bash: ssh://git.<myhiddenservice>.onion/git/: No such file or directory


fatal: repository 'git.<myhiddenservice>.onion/git/<myproject>.git' does not exist

2 Answers 2


torsocks is the way to go. You may need to install it separately from Tor if it is not installed automatically.

  • Make sure Tor is running: systemctl status tor
  • Run your command through torsocks: torsock git pull or torsocks ssh abcxyz.onion

Another option is to run torsocks --shell. This will make all commands in that shell automatically run through Tor. This will end if you exit from the shell or close the terminal window.


While marked answer is 100% correct I use a bit different approach. For ssh connections using OpenSSH client I utilze ProxyCommand for *.onion sites in the following way:

Host *.onion
        ProxyCommand                    socat STDIO SOCKS4A:<tor socks hostname or IP>:%h:%p,socksport=9050

This should also be the only change needed for git ssh connections.

In a way it may or may not be a good thing: while using torsocks will force ALL connections (ie. to submodules) to go through TOR network, using proxy command above will only route hidden services through TOR. Please evaluate the risk before going this route.

  • hey Tomek years has passed but your solution is still working , thanks a lot!
    – Martin
    Commented Feb 21, 2021 at 2:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .