September 27, 2019
🔐 Seamless .onion and torified git remotes
- Repository: https://github.com/agentofuser/git-remote-tor/
- Crate: https://crates.io/crates/git-remote-tor
- Contact: https://keybase.io/agentofuser
I wanted an easy way to clone from git repos hosted over Tor onion services
.onion addresses). That is, without typing
torsocks before every git
command that touched the network like
git fetch, etc.
Especially because I use the wonderful magit a lot of the time and won’t be typing those commands myself.
git clone tor::http://3lytcgmoe2j75c6t.onion/
Also works for your everyday Microsoft GitHub repos:
git clone tor::https://github.com/agentofuser/logit.git
Crucially, note that the
tor:: prefix gets automatically added to
.git/config as part of the remote’s URL. So that’s the only time you have to
do anything special.
After this you do
git fetch origin,
git pull, etc. just like everyone else.
Yes, there is a little one-time setup which I will make easier over time by distributing the binary on system package managers.
To install on macOS:
brew install tor torsocks rust cargo install git-remote-tor
Then before hitting the network, make sure the tor process is running:
brew services start tor
(Don’t worry, it will error-out if tor is offline, not send traffic over clearnet.)
How do you tell Git to use this? No need. It’s smart enough to look for
git-remote-tor in your
PATH and call it with the repo’s URL when you prefix
🧠 But Why?
Think of onion services not just as a way to serve websites or ssh on high uptime hosts, but as a way for your computer to connect to your friend’s computer intermittently. You know, peer-to-peer.
Onion services are a great way to do NAT traversal and dynamic DNS for free, and you get some sweet privacy to boot.
💪 Repos of the World, Onionize!
This is how you serve a read-only repo over an onion service:
git clone --bare https://github.com/agentofuser/logit.git cd logit.git # sets up repo for the git dumb http protocol mv hooks/post-update.sample hooks/post-update git update-server-info # if you haven't installed it yet go get github.com/nogoegst/onionize/cmd/onionize # then drum the rolls and... onionize .
Done! Grab the onion address that onionize spits out to stdout and go
git-remote-url and your own version of
I know, right? 🤯
Hey I’m just the guy writing the docs, porting a 9 line shell script to Rust for no reason, and pushing to package managers.
The actual work was done by nicoo on the Tor trac and for that I’m forever grateful! 🙏
Written by Helder S Ribeiro (@agentofuser) who lives and works on 🌎 Earth building useful things. You can follow him on Twitter.