ScriptedArtsOfficial

Install Tor on Ubuntu 18.04 Bionic Beaver Linux / Setup

May 18th, 2018
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. Objective
  2. The objective is to install Tor on Ubuntu 18.04 Bionic Beaver. This guide will also provide you with some basic configuration and usage of Tor network in order to conceal your identity.
  3. Operating System and Software Versions
  4. Operating System: - Ubuntu 18.04 Bionic Beaver
  5. Software: - Tor version 0.3.2.9
  6. Requirements
  7. Privileged access to your Ubuntu System as root or via sudo command is required.
  8. Difficulty
  9. EASY
  10. Conventions
  11. # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  12. $ - requires given linux commands to be executed as a regular non-privileged user
  13. Instructions
  14. Install Tor on Ubuntu
  15. Let's start by Tor installation on Ubuntu 18.04 system. To install Tor execute the below apt command:
  16. $ sudo apt install tor
  17. By default Tor listens for all requests on port 9050. Confirm that Tor is up and running on this specific port by using the ss command:
  18.  
  19. $ ss -nlt
  20. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  21. LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
  22. LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
  23. LISTEN 0 128 127.0.0.1:9050 0.0.0.0:*
  24.  
  25. You can also check for the Tor version by entering:
  26. $ tor --version
  27. Tor version 0.3.2.9 (git-64a719dd25a21acb).
  28. Tor Network connection test
  29. At this stage we are going to test our Tor installation by obtaining an external IP address via Tor network. First, check your external IP address:
  30. $ wget -qO - https://api.ipify.org; echo
  31. 89.137.173.226
  32. Next, use the torsocks command to obtain your external IP address via Tor network:
  33. $ torsocks wget -qO - https://api.ipify.org; echo
  34. 185.220.101.13
  35.  
  36.  
  37. Torify your shell
  38. Set your shell to use torsocks as default for any command. This will allow you to use commands without prefixing them with the torsocks command. To enable torsocks for your current shell session enter:
  39. $ source torsocks on
  40. Tor mode activated. Every command will be torified for this shell.
  41. Test your torified shell but this time without the torsocks command prefix:
  42. $ wget -qO - https://api.ipify.org; echo
  43. 185.220.101.13
  44. To make this change permanent for all your new shell sessions and after reboot enter:
  45. $ echo ". torsocks on" >> ~/.bashrc
  46. To disable Tor for your current shell enter:
  47. $ source torsocks off
  48. Tor mode deactivated. Command will NOT go through Tor anymore.
  49. Enable Tor Control Port
  50. Next, we are going to enable Tor's Control Port which will allow as to communicate with Tor local installation. We will also password protect Tor connection with password eg. my-tor-password. First set your password variable with your password:
  51. torpass=$(tor --hash-password "my-tor-password")
  52. Next, enable Tor control port and insert our previously hashed password:
  53. $ printf "HashedControlPassword $torpass\nControlPort 9051\n" | sudo tee -a /etc/tor/torrc
  54. Restart Tor to apply changes:
  55. $ sudo /etc/init.d/tor restart
  56. Your Tor service should be now listening on both ports 9050 and 9051:
  57.  
  58. $ $ ss -nlt
  59. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  60. LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
  61. LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
  62. LISTEN 0 128 127.0.0.1:9050 0.0.0.0:*
  63. LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
  64. LISTEN 0 128 127.0.0.1:9051 0.0.0.0:*
  65.  
  66.  
  67.  
  68.  
  69. Connect to Tor Control Port
  70. Using Tor Control Port we are able to communicate with Tor and issue commands. For example let's use the telnet command and request a new Tor circuit and clear cache:
  71.  
  72. $ telnet 127.0.0.1 9051
  73. Trying 127.0.0.1...
  74. Connected to 127.0.0.1.
  75. Escape character is '^]'.
  76. AUTHENTICATE "my-tor-password"
  77. 250 OK
  78. SIGNAL NEWNYM
  79. 250 OK
  80. SIGNAL CLEARDNSCACHE
  81. 250 OK
  82. quit
  83. 250 closing connection
  84. Connection closed by foreign host.
  85.  
  86.  
  87.  
  88. On Line 5 we have entered AUTHENTICATE command and our Tor password. On Line 7 and Line 9 we asked Tor for a new circuit and clean cache.
  89.  
  90. The communication with the Tor control port can also be shell scripted. Consider the following example of requesting a new clean circuit:
  91. $ source torsocks off
  92. Tor mode deactivated. Command will NOT go through Tor anymore.
  93. $ torsocks wget -qO - https://api.ipify.org; echo
  94. 103.1.206.100
  95. $ echo -e 'AUTHENTICATE "my-tor-password"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
  96. 250 OK
  97. 250 OK
  98. 250 closing connection
  99. $ torsocks wget -qO - https://api.ipify.org; echo
  100. 185.100.87.206
  101. Configure Browser to use Tor network
  102. Lastly, configure your Firefox browser to use local Tor host!
Advertisement
Add Comment
Please, Sign In to add comment