In office I have a limitation on internet due to Fortinet. I can access to website by using Tor browser but not enable to download and make updates through terminal.

Is there anyway to bypass the guard for terminal?

  • 1
    Tor essentially sets up a SOCKS proxy, but apt doesn't support SOCKS proxies. Look into something like redsocks which will work as a HTTP proxy and forward connections to Tor's SOCKS proxy. – muru Jun 15 '17 at 6:30
  • 2
    Check your company's policy on outside Internet access - You could get fired. – waltinator Jun 15 '17 at 14:25

This page described how to use torify for terminal

torify is a simple wrapper that attempts to find the best underlying Tor wrapper available on a system. It calls torsocks or tsocks with a tor specific configuration file.

As first thing install the software, tor is usually found on all the repository so for Debian, Ubuntu and Mint you just have to type:

sudo apt-get install tor

In this example we’ll keep all the standard configuration but 2 things, in the file /etc/tor/torrc you should uncomment the directive:

ControlPort 9051

And set

CookieAuthentication 0

With these 2 options we set the port on which Tor will listen for local connections from Tor controller applications, and we tell to Tor that we don’t need an authentication, so any program can control Tor (don’t do this on a shared computer or server), later in this post I’ll show how to set a password, once changed save the file and restart tor with the command:

sudo /etc/init.d/tor restart

And now a simple example that shows how to use the command torify and start a new session on tor from the Linux terminal, as first thing I get my public IP address with:

$  curl ifconfig.me

So is my public IP, now I use torify before the command curl in the command line :

$ torify curl ifconfig.me 2>/dev/null

As you can see now I browse on the net with a different Ip:, but from the command line I can also force Tor to start a “new session” with the command:

echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 9051
250 OK
250 OK
250 closing connection

This small script connects to port 9051 and issue the command “signal newnym” that will make Tor switch to clean circuits, so new application requests don’t share any circuits with old ones, now if I check my IP I expect to see a new one:

$ torify curl ifconfig.me 2>/dev/null

In this small example I’ve used curl to get my ip address, but with torify you could use almost any terminal program, such as ssh, wget, w3m or BitchX.

How to set a password for Tor

If you are in a shared environment it’s better to set up a password for Tor, here it’s how you can do it in a few steps:

  1. Generating your encrypted password:

In a terminal type:

tor --hash-password "passwordhere"

This will generate a password hash, you will need to save this for inserting into the TOR configuration file in the next step. (This is the hash for “passwordhere”, 16:113BD60B17CD1E98609013B4426860D576F7096C189184808AFF551F65)

  1. Editing the Tor configuration file :

Open the file /etc/tor/torrc and comment the line we set before:

#CookieAuthentication 0

Next find the line:

#HashedControlPassword 16:2283409283049820409238409284028340238409238

remove the # at the beginning and replace the password hash that is currently there with the hash you have just generated.

So with the hash generated in this example the configuration would be:

HashedControlPassword 16:113BD60B17CD1E98609013B4426860D576F7096C189184808AFF551F65

Save your changes.

  1. Restart TOR:

Restart Tor so it get the new directives with:

sudo /etc/init.d/tor restart

Now you can use the former command to connect to teh Tor daemon, but using your password, so for me this would be:

echo -e 'AUTHENTICATE "passwordhere"\r\nsignal NEWNYM\r\nQUIT' | nc 9051


  • >sudo apt-get install tor E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? -- Also /etc/tor/torrc no tor folder at that direction – isifzade Jun 15 '17 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.