So I have tor installed and have it enabled with systemctl, so tor.service starts on boot and I can automatically just configure SOCKS5 proxies to

Now, tor has a few minor annoyances. Since it's well known, some sites block tor exit nodes. I came up with a solution. I bought a VPS and use an SSH tunnel to it as a SOCKS5 proxy. If I start the tunnel with the torsocks command, then the actual route looks like:

me > tor network > VPS > internet

The command I use is a one liner:

torsocks sshpass -p password ssh -p 69 -D 9040 user@IP

And it works fine. It launches a terminal and as long as I keep that terminal open, it worked.

Now what I want is for it to launch on system boot and run in the background. I tried using nohup while booted but it didn't work. It just didn't start the proxy. I tried systemctl, I tried gnome's .gnomerc, everything.


My current solution:

[me@me ~]$ echo 'torsocks sshpass -p password ssh -p 69 -D 9040 user@IP' > proxy
[me@me ~]$ sudo chmod +x proxy

And then whenever I need it I just do:

  • If you are paying for a VPS, and ultimately your traffic is coming out of your VPS, what is the point of having TOR in the middle as opposed to running squid on the VPS, and run port forwarding through a SSH connection to the squid SOCKS proxy? Or am I misunderstanding something? Just curious.
    – Jason Rush
    Dec 23, 2015 at 23:36
  • Well, just a VPS on its own isn't as secure as the tor network. There's so many things that could go wrong. It could be compromised, authorities could raid the server, the host could give up my IP, etc. However, if I have tor in the middle, even if any of those things happen, I'm still safe.
    – Awn
    Dec 23, 2015 at 23:48
  • As long as your method of paying for the VPS doesn't compromise your anonymity either (ie credit cards, street address, etc). If the payments are anonymized/safe, then agreed.
    – Jason Rush
    Dec 23, 2015 at 23:51

1 Answer 1


The cleanest solution is to let systemd handle your proxy as well, once the for network is up. See https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files For info on writing your own service file and https://wiki.archlinux.org/index.php/Systemd/User#How_it_works for more details if you just want it for your user. I would suggest replacing your sshpass & password call with a public key instead, which I hope your VPS supports.

An example for your usecase is

Description=Starts torsocks script

ExecStart=torsocks sshpass -p password ssh -p 69 -D 9040 user@IP

  • I tried using systemctl but it just didn't start the proxy. A ps | grep ssh returned nothing too and I couldn't connect to it. Am I right in assuming the proxy has to be started under my user for me to be able to connect?
    – Awn
    Dec 23, 2015 at 23:46
  • Define just didn't start? What did the logs say? From my understanding, no. But it's better than root. (The previous yes here was relating to the environment variable. Network wise it doesn't matter)
    – D.S
    Dec 24, 2015 at 0:01
  • Well when I tried connecting to it from firefox, it said that the proxy server is refusing connections, the same error message that appears when the proxy isn't started. How do I check logs of systemctl? systemctl status?
    – Awn
    Dec 24, 2015 at 18:40
  • Yes, systemctl --user status <unitfile>, if you chose to install it for your user
    – D.S
    Dec 26, 2015 at 9:29

You must log in to answer this question.

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