mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-29 07:26:22 +01:00
42 lines
27 KiB
JSON
42 lines
27 KiB
JSON
{
|
||
"post": {
|
||
"html": "<p>There are many reasons you might want to browse anonymously which can be accomplished by using <a href=\"https://www.torproject.org\">Tor</a>. The setup instructions on Tor’s website are quite scattered and outdated so here are some steps to setup Tor on macOS with a simple automated script at the end.</p><!-- more -->\n<p>I’m using macOS Catalina (10.15) for the following instructions but it should work on almost any macOS version.</p>\n<h2 id=\"tor-browser\"><a href=\"#tor-browser\" aria-label=\"tor browser permalink\" class=\"anchor\"><span>#</span></a>Tor Browser</h2>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n <span\n class=\"gatsby-resp-image-wrapper\"\n style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px;\"\n >\n <span\n class=\"gatsby-resp-image-background-image\"\n style=\"padding-bottom: 79.67625899280576%; position: relative; bottom: 0; left: 0; display: block;\"\n ></span>\n <img\n class=\"gatsby-resp-image-image\"\n alt=\"Tor Browser\"\n title=\"Tor Browser\"\n src=\"/static/d254d922666449c4550bd8591a72a6f4/0f489/tor-browser.png\"\n srcset=\"/static/d254d922666449c4550bd8591a72a6f4/896af/tor-browser.png 158w,\n/static/d254d922666449c4550bd8591a72a6f4/b70ff/tor-browser.png 315w,\n/static/d254d922666449c4550bd8591a72a6f4/0f489/tor-browser.png 630w,\n/static/d254d922666449c4550bd8591a72a6f4/85b6f/tor-browser.png 945w,\n/static/d254d922666449c4550bd8591a72a6f4/4d498/tor-browser.png 1260w,\n/static/d254d922666449c4550bd8591a72a6f4/fce11/tor-browser.png 2224w\"\n sizes=\"(max-width: 630px) 100vw, 630px\"\n loading=\"lazy\"\n />\n </span>\n <figcaption class=\"gatsby-resp-image-figcaption\">Tor Browser</figcaption>\n </figure></p>\n<p>The most simple way to surf anonymously with Tor is to just grab <a href=\"https://www.torproject.org/projects/torbrowser.html.en\">Tor Browser</a>. It’s a modified version of <a href=\"https://www.mozilla.org/en-US/firefox/organizations/\">Firefox Extended Support Release (ESR)</a> with Tor and some extensions (Torbutton, TorLauncher, NoScript, and HTTPS-Everywhere) built right in. Upon start, Tor Browser automatically starts the required Tor background processes and routes traffic through the Tor network. That’s the way to go if you want the highest level of protection without much further configuration.</p>\n<p>But it’s based on an older version of Firefox and there might be more you want to do anonymously on your machine than just browsing the web, like accessing resources via the Terminal or any other app. Or just use the browser you’re used to.</p>\n<p>For this you need to have Tor installed on your system and additionally set specific proxy values in your network preferences after you’ve started Tor.</p>\n<div class=\"alert alert-info\">\n <p>Be aware that the instructions and the script mentioned below will not make whatever you do on the web anonymous. Much depends on your browsing habits, what apps you're using, and none of the methods below will offer the same level of protection than <a href=\"https://www.torproject.org/projects/torbrowser.html.en\">Tor Browser</a> out of the box. You have been warned.</p>\n</div>\n<h2 id=\"install-tor\"><a href=\"#install-tor\" aria-label=\"install tor permalink\" class=\"anchor\"><span>#</span></a>Install Tor</h2>\n<p>Contrary to the weirdly outdated <a href=\"https://www.torproject.org/docs/tor-doc-osx.html.en\">install instructions on Tor’s website</a> (hey, remember Macports?), installing Tor on macOS is super simple with <a href=\"http://brew.sh\">Homebrew</a>.</p>\n<p>In your Terminal execute:</p>\n<pre class=\"nord vscode-highlight\" data-language=\"bash\"><code class=\"vscode-highlight-code\"><span class=\"vscode-highlight-line\"><span class=\"mtk1\">brew install tor</span></span></code></pre>\n<p>Then you can start it up by running:</p>\n<pre class=\"nord vscode-highlight\" data-language=\"bash\"><code class=\"vscode-highlight-code\"><span class=\"vscode-highlight-line\"><span class=\"mtk1\">tor</span></span></code></pre>\n<p>Congratulations, you now have Tor running on your system. But none of your network traffic is routed through it yet.</p>\n<p>In order for all your system traffic being routed through Tor you need to adjust your system’s network proxy settings which you can either do visually in the System Preferences or programmatically via macOS’s builtin <code>networksetup</code>.</p>\n<h2 id=\"set-network-proxy-settings-via-system-preferences\"><a href=\"#set-network-proxy-settings-via-system-preferences\" aria-label=\"set network proxy settings via system preferences permalink\" class=\"anchor\"><span>#</span></a>Set network proxy settings via System Preferences</h2>\n<p>You can do this under <em>System Preferences > Network</em> by creating a specific Tor network location for it:</p>\n<ol>\n<li>From Location dropdown at the top, select <em>Edit Locations…</em></li>\n<li>Create a new location by hitting the plus button and name it <em>Tor</em>. Hitting Done will select the new location which is now ready to be configured.</li>\n<li>Go to <em>Advanced > Proxies</em> and activate <em>SOCKS Proxy</em> and add those values:</li>\n<li><em>SOCKS proxy server</em>: <code>localhost</code></li>\n<li><em>Port</em>: <code>9050</code></li>\n</ol>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n <span\n class=\"gatsby-resp-image-wrapper\"\n style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px;\"\n >\n <span\n class=\"gatsby-resp-image-background-image\"\n style=\"padding-bottom: 86.53846153846155%; position: relative; bottom: 0; left: 0; display: block;\"\n ></span>\n <img\n class=\"gatsby-resp-image-image\"\n alt=\"Network Settings\"\n title=\"Network Settings\"\n src=\"/static/f9446a43a83f03d45a49c0667b8705cf/0f489/tor-osx-proxy.png\"\n srcset=\"/static/f9446a43a83f03d45a49c0667b8705cf/896af/tor-osx-proxy.png 158w,\n/static/f9446a43a83f03d45a49c0667b8705cf/b70ff/tor-osx-proxy.png 315w,\n/static/f9446a43a83f03d45a49c0667b8705cf/0f489/tor-osx-proxy.png 630w,\n/static/f9446a43a83f03d45a49c0667b8705cf/85b6f/tor-osx-proxy.png 945w,\n/static/f9446a43a83f03d45a49c0667b8705cf/4d498/tor-osx-proxy.png 1260w,\n/static/f9446a43a83f03d45a49c0667b8705cf/cd0ad/tor-osx-proxy.png 1560w\"\n sizes=\"(max-width: 630px) 100vw, 630px\"\n loading=\"lazy\"\n />\n </span>\n <figcaption class=\"gatsby-resp-image-figcaption\">Network Settings</figcaption>\n </figure></p>\n<p>After hitting <em>OK</em> & <em>Apply</em> at the initial network screen, you can easily switch to this newly created location from your menu bar under <em> > Location</em> whenever you start up Tor.</p>\n<p>Switching to the Tor location routes all network traffic on your system through Tor. Note that you have to repeat those steps for every other network interface if you use, say, Wi-Fi and Ethernet interchangeably.</p>\n<h2 id=\"all-in-one-go-start-tor--set-network-proxy-settings-automatically\"><a href=\"#all-in-one-go-start-tor--set-network-proxy-settings-automatically\" aria-label=\"all in one go start tor set network proxy settings automatically permalink\" class=\"anchor\"><span>#</span></a>All in one go: start Tor & set network proxy settings automatically</h2>\n<p>When you’re already in the Terminal to start up Tor, additionally setting the network settings involves a lot of fiddling around. Ain’t nobody got time for that.</p>\n<p>Thankfully macOS provides a way to programmatically set those proxy values via the <code>networksetup</code> utility. I’ve found a <a href=\"http://leonid.shevtsov.me/en/an-easy-way-to-use-tor-on-os-x\">nice script</a> for this but running it opened multiple admin password prompts. So I extended it a bit to make it more user friendly.</p>\n<p>In a nutshell, this shell script asks you for your admin password upfront, starts up Tor, and sets all required proxy network settings automatically:</p>\n<pre class=\"nord vscode-highlight\" data-language=\"bash\"><code class=\"vscode-highlight-code\"><span class=\"vscode-highlight-line\"><span class=\"mtk5\">#!/usr/bin/env bash</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk5\"># 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\">INTERFACE=Wi-Fi</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk5\"># Ask for the administrator password upfront</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\">sudo -v</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk5\"># Keep-alive: update existing `sudo` time stamp until finished</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk3\">while</span><span class=\"mtk1\"> </span><span class=\"mtk10\">true</span><span class=\"mtk3\">;</span><span class=\"mtk1\"> </span><span class=\"mtk3\">do</span><span class=\"mtk1\"> sudo -n </span><span class=\"mtk10\">true</span><span class=\"mtk3\">;</span><span class=\"mtk1\"> sleep 60</span><span class=\"mtk3\">;</span><span class=\"mtk1\"> </span><span class=\"mtk10\">kill</span><span class=\"mtk1\"> -0 </span><span class=\"mtk14\">"</span><span class=\"mtk3\">$</span><span class=\"mtk8\">$</span><span class=\"mtk14\">"</span><span class=\"mtk1\"> </span><span class=\"mtk3\">||</span><span class=\"mtk1\"> </span><span class=\"mtk10\">exit</span><span class=\"mtk3\">;</span><span class=\"mtk1\"> </span><span class=\"mtk3\">done</span><span class=\"mtk1\"> </span><span class=\"mtk3\">2></span><span class=\"mtk1\">/dev/null </span><span class=\"mtk3\">&</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk5\"># trap ctrl-c and call disable_proxy()</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk3\">function</span><span class=\"mtk1\"> </span><span class=\"mtk10\">disable_proxy()</span><span class=\"mtk1\"> </span><span class=\"mtk14\">{</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"> sudo networksetup -setsocksfirewallproxystate </span><span class=\"mtk3\">$</span><span class=\"mtk8\">INTERFACE</span><span class=\"mtk1\"> off</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"> </span><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"$(</span><span class=\"mtk13\">tput setaf 64</span><span class=\"mtk14\">)"</span><span class=\"mtk1\"> </span><span class=\"mtk5\">#green</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"> </span><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"</span><span class=\"mtk13\">SOCKS proxy disabled.</span><span class=\"mtk14\">"</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"> </span><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"$(</span><span class=\"mtk13\">tput sgr0</span><span class=\"mtk14\">)"</span><span class=\"mtk1\"> </span><span class=\"mtk5\"># color reset</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk14\">}</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">trap</span><span class=\"mtk1\"> disable_proxy INT</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk5\"># Let's roll</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\">sudo networksetup -setsocksfirewallproxy </span><span class=\"mtk3\">$</span><span class=\"mtk8\">INTERFACE</span><span class=\"mtk1\"> 127.0.0.1 9050 off</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\">sudo networksetup -setsocksfirewallproxystate </span><span class=\"mtk3\">$</span><span class=\"mtk8\">INTERFACE</span><span class=\"mtk1\"> on</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"$(</span><span class=\"mtk13\">tput setaf 64</span><span class=\"mtk14\">)"</span><span class=\"mtk1\"> </span><span class=\"mtk5\"># green</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"</span><span class=\"mtk13\">SOCKS proxy 127.0.0.1:9050 enabled.</span><span class=\"mtk14\">"</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"$(</span><span class=\"mtk13\">tput setaf 136</span><span class=\"mtk14\">)"</span><span class=\"mtk1\"> </span><span class=\"mtk5\"># orange</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"</span><span class=\"mtk13\">Starting Tor...</span><span class=\"mtk14\">"</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk10\">echo</span><span class=\"mtk1\"> </span><span class=\"mtk14\">"$(</span><span class=\"mtk13\">tput sgr0</span><span class=\"mtk14\">)"</span><span class=\"mtk1\"> </span><span class=\"mtk5\"># color reset</span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\"></span></span>\n<span class=\"vscode-highlight-line\"><span class=\"mtk1\">tor</span></span></code></pre>\n<p>Save this script under something like <code>tor.sh</code> in one of your sourced <code>bin</code> folders, make it executable with <code>chmod + x</code> and use it as a replacement for the general <code>tor</code> command. So you can just run</p>\n<pre class=\"nord vscode-highlight\" data-language=\"bash\"><code class=\"vscode-highlight-code\"><span class=\"vscode-highlight-line\"><span class=\"mtk1\">tor.sh</span></span></code></pre>\n<p>and Tor should run smoothly on your system without additional configuration:</p>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n <span\n class=\"gatsby-resp-image-wrapper\"\n style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px;\"\n >\n <span\n class=\"gatsby-resp-image-background-image\"\n style=\"padding-bottom: 82.84625158831004%; position: relative; bottom: 0; left: 0; display: block;\"\n ></span>\n <img\n class=\"gatsby-resp-image-image\"\n alt=\"Tor running in Terminal\"\n title=\"Tor running in Terminal\"\n src=\"/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/0f489/tor-osx-terminal.png\"\n srcset=\"/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/896af/tor-osx-terminal.png 158w,\n/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/b70ff/tor-osx-terminal.png 315w,\n/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/0f489/tor-osx-terminal.png 630w,\n/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/85b6f/tor-osx-terminal.png 945w,\n/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/4d498/tor-osx-terminal.png 1260w,\n/static/d4c7f5d2fd6bc6d99de5395bf8ff88f6/f70c0/tor-osx-terminal.png 1574w\"\n sizes=\"(max-width: 630px) 100vw, 630px\"\n loading=\"lazy\"\n />\n </span>\n <figcaption class=\"gatsby-resp-image-figcaption\">Tor running in Terminal</figcaption>\n </figure></p>\n<p>Verify you’re indeed browsing over the Tor network by going to <a href=\"https://check.torproject.org\">check.torproject.org</a>.</p>\n<p>When you’re done, just exit the script with <kbd>ctrl</kbd> + <kbd>c</kbd> and the network settings will be reverted to their previous configuration.</p>\n<h2 id=\"non-standard-apps\"><a href=\"#non-standard-apps\" aria-label=\"non standard apps permalink\" class=\"anchor\"><span>#</span></a>Non-standard apps</h2>\n<p>Some apps are just not good Mac citizens and use their own network settings, ignoring macOS system network proxy settings. E.g. older versions of Google Chrome were using their own custom network settings and therefore were not routing their web traffic through the proxy configured in System Preferences.</p>\n<p>But the most recent Chrome version automatically picks up macOS’s native proxy settings, as does the most recent version of Firefox.</p>\n<p>Always <a href=\"https://check.torproject.org\">check</a> your Tor connection with whatever app you’re using and if needed set the proxy preferences manually in the respective app with:</p>\n<ul>\n<li><em>SOCKS proxy server</em>: <code>localhost</code></li>\n<li><em>Port</em>: <code>9050</code></li>\n</ul>\n<style class=\"vscode-highlight-styles\">\n \n .nord {\nbackground-color: #2e3440;\ncolor: #d8dee9;\n}\n\n.nord .mtk1 { color: #D8DEE9FF; }\n.nord .mtk2 { color: #2E3440FF; }\n.nord .mtk3 { color: #81A1C1; }\n.nord .mtk4 { color: #8FBCBB; }\n.nord .mtk5 { color: #616E88; }\n.nord .mtk6 { color: #EBCB8B; }\n.nord .mtk7 { color: #B48EAD; }\n.nord .mtk8 { color: #D8DEE9; }\n.nord .mtk9 { color: #D08770; }\n.nord .mtk10 { color: #88C0D0; }\n.nord .mtk11 { color: #5E81AC; }\n.nord .mtk12 { color: #BF616A; }\n.nord .mtk13 { color: #A3BE8C; }\n.nord .mtk14 { color: #ECEFF4; }\n.nord .mtki { font-style: italic; }\n.nord .mtkb { font-weight: bold; }\n.nord .mtku { text-decoration: underline; text-underline-position: under; }\n</style>",
|
||
"excerpt": "There are many reasons you might want to browse anonymously which can be accomplished by using Tor. The setup instructions on Tor’s website…",
|
||
"frontmatter": {
|
||
"type": "post",
|
||
"title": "Simple Tor setup on macOS",
|
||
"image": {
|
||
"childImageSharp": {
|
||
"fluid": {
|
||
"aspectRatio": 3.2,
|
||
"src": "/static/c87c817b4191fb48e9ca4419c0c70bb8/3995d/teaser-tor.png",
|
||
"srcSet": "/static/c87c817b4191fb48e9ca4419c0c70bb8/f0031/teaser-tor.png 200w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/cad89/teaser-tor.png 400w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/3995d/teaser-tor.png 800w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/32ce4/teaser-tor.png 1200w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/1ed7e/teaser-tor.png 1600w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/19dc3/teaser-tor.png 1920w",
|
||
"srcWebp": "/static/c87c817b4191fb48e9ca4419c0c70bb8/240ac/teaser-tor.webp",
|
||
"srcSetWebp": "/static/c87c817b4191fb48e9ca4419c0c70bb8/04c4c/teaser-tor.webp 200w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/ebea1/teaser-tor.webp 400w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/240ac/teaser-tor.webp 800w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/823f0/teaser-tor.webp 1200w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/9e49e/teaser-tor.webp 1600w,\n/static/c87c817b4191fb48e9ca4419c0c70bb8/68ae1/teaser-tor.webp 1920w",
|
||
"sizes": "(max-width: 800px) 100vw, 800px",
|
||
"originalImg": "/static/c87c817b4191fb48e9ca4419c0c70bb8/19dc3/teaser-tor.png",
|
||
"originalName": "teaser-tor.png",
|
||
"presentationWidth": 800,
|
||
"presentationHeight": 250
|
||
}
|
||
},
|
||
"fields": null
|
||
},
|
||
"toc": true,
|
||
"author": "Matthias Kretschmann",
|
||
"updated": "2019-11-07T22:52:46.000Z",
|
||
"tags": ["tutorial", "tor", "macos", "goodies", "apple"],
|
||
"linkurl": null,
|
||
"style": null,
|
||
"changelog": null
|
||
},
|
||
"fields": {
|
||
"slug": "/simple-tor-setup-on-mac-os-x",
|
||
"date": "2015-08-02T19:57:30.912Z",
|
||
"githubLink": "https://github.com/kremalicious/blog/tree/main/content/posts/2015-08-02-simple-tor-setup-on-mac-os-x/index.md"
|
||
},
|
||
"rawMarkdownBody": "\nThere are many reasons you might want to browse anonymously which can be accomplished by using [Tor](https://www.torproject.org). The setup instructions on Tor's website are quite scattered and outdated so here are some steps to setup Tor on macOS with a simple automated script at the end.\n\n<!-- more -->I'm using macOS Catalina (10.15) for the following instructions but it should work on almost any macOS version.\n\n## Tor Browser\n\n![Tor Browser](tor-browser.png)\n\nThe most simple way to surf anonymously with Tor is to just grab [Tor Browser](https://www.torproject.org/projects/torbrowser.html.en). It's a modified version of [Firefox Extended Support Release (ESR)](https://www.mozilla.org/en-US/firefox/organizations/) with Tor and some extensions (Torbutton, TorLauncher, NoScript, and HTTPS-Everywhere) built right in. Upon start, Tor Browser automatically starts the required Tor background processes and routes traffic through the Tor network. That's the way to go if you want the highest level of protection without much further configuration.\n\nBut it's based on an older version of Firefox and there might be more you want to do anonymously on your machine than just browsing the web, like accessing resources via the Terminal or any other app. Or just use the browser you're used to.\n\nFor this you need to have Tor installed on your system and additionally set specific proxy values in your network preferences after you've started Tor.\n\n<div class=\"alert alert-info\">\n <p>Be aware that the instructions and the script mentioned below will not make whatever you do on the web anonymous. Much depends on your browsing habits, what apps you're using, and none of the methods below will offer the same level of protection than <a href=\"https://www.torproject.org/projects/torbrowser.html.en\">Tor Browser</a> out of the box. You have been warned.</p>\n</div>\n\n## Install Tor\n\nContrary to the weirdly outdated [install instructions on Tor's website](https://www.torproject.org/docs/tor-doc-osx.html.en) (hey, remember Macports?), installing Tor on macOS is super simple with [Homebrew](http://brew.sh).\n\nIn your Terminal execute:\n\n```bash\nbrew install tor\n```\n\nThen you can start it up by running:\n\n```bash\ntor\n```\n\nCongratulations, you now have Tor running on your system. But none of your network traffic is routed through it yet.\n\nIn order for all your system traffic being routed through Tor you need to adjust your system's network proxy settings which you can either do visually in the System Preferences or programmatically via macOS's builtin `networksetup`.\n\n## Set network proxy settings via System Preferences\n\nYou can do this under _System Preferences > Network_ by creating a specific Tor network location for it:\n\n1. From Location dropdown at the top, select _Edit Locations..._\n2. Create a new location by hitting the plus button and name it _Tor_. Hitting Done will select the new location which is now ready to be configured.\n3. Go to _Advanced > Proxies_ and activate _SOCKS Proxy_ and add those values:\n\n- _SOCKS proxy server_: `localhost`\n- _Port_: `9050`\n\n![Network Settings](tor-osx-proxy.png)\n\nAfter hitting _OK_ & _Apply_ at the initial network screen, you can easily switch to this newly created location from your menu bar under _ > Location_ whenever you start up Tor.\n\nSwitching to the Tor location routes all network traffic on your system through Tor. Note that you have to repeat those steps for every other network interface if you use, say, Wi-Fi and Ethernet interchangeably.\n\n## All in one go: start Tor & set network proxy settings automatically\n\nWhen you're already in the Terminal to start up Tor, additionally setting the network settings involves a lot of fiddling around. Ain't nobody got time for that.\n\nThankfully macOS provides a way to programmatically set those proxy values via the `networksetup` utility. I've found a [nice script](http://leonid.shevtsov.me/en/an-easy-way-to-use-tor-on-os-x) for this but running it opened multiple admin password prompts. So I extended it a bit to make it more user friendly.\n\nIn a nutshell, this shell script asks you for your admin password upfront, starts up Tor, and sets all required proxy network settings automatically:\n\n```bash\n#!/usr/bin/env bash\n\n# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'\nINTERFACE=Wi-Fi\n\n# Ask for the administrator password upfront\nsudo -v\n\n# Keep-alive: update existing `sudo` time stamp until finished\nwhile true; do sudo -n true; sleep 60; kill -0 \"$$\" || exit; done 2>/dev/null &\n\n# trap ctrl-c and call disable_proxy()\nfunction disable_proxy() {\n sudo networksetup -setsocksfirewallproxystate $INTERFACE off\n echo \"$(tput setaf 64)\" #green\n echo \"SOCKS proxy disabled.\"\n echo \"$(tput sgr0)\" # color reset\n}\ntrap disable_proxy INT\n\n# Let's roll\nsudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off\nsudo networksetup -setsocksfirewallproxystate $INTERFACE on\n\necho \"$(tput setaf 64)\" # green\necho \"SOCKS proxy 127.0.0.1:9050 enabled.\"\necho \"$(tput setaf 136)\" # orange\necho \"Starting Tor...\"\necho \"$(tput sgr0)\" # color reset\n\ntor\n```\n\nSave this script under something like `tor.sh` in one of your sourced `bin` folders, make it executable with `chmod + x` and use it as a replacement for the general `tor` command. So you can just run\n\n```bash\ntor.sh\n```\n\nand Tor should run smoothly on your system without additional configuration:\n\n![Tor running in Terminal](tor-osx-terminal.png)\n\nVerify you're indeed browsing over the Tor network by going to [check.torproject.org](https://check.torproject.org).\n\nWhen you're done, just exit the script with <kbd>ctrl</kbd> + <kbd>c</kbd> and the network settings will be reverted to their previous configuration.\n\n## Non-standard apps\n\nSome apps are just not good Mac citizens and use their own network settings, ignoring macOS system network proxy settings. E.g. older versions of Google Chrome were using their own custom network settings and therefore were not routing their web traffic through the proxy configured in System Preferences.\n\nBut the most recent Chrome version automatically picks up macOS's native proxy settings, as does the most recent version of Firefox.\n\nAlways [check](https://check.torproject.org) your Tor connection with whatever app you're using and if needed set the proxy preferences manually in the respective app with:\n\n- _SOCKS proxy server_: `localhost`\n- _Port_: `9050`\n",
|
||
"tableOfContents": "<ul>\n<li><a href=\"/simple-tor-setup-on-mac-os-x/#tor-browser\">Tor Browser</a></li>\n<li><a href=\"/simple-tor-setup-on-mac-os-x/#install-tor\">Install Tor</a></li>\n<li><a href=\"/simple-tor-setup-on-mac-os-x/#set-network-proxy-settings-via-system-preferences\">Set network proxy settings via System Preferences</a></li>\n<li><a href=\"/simple-tor-setup-on-mac-os-x/#all-in-one-go-start-tor--set-network-proxy-settings-automatically\">All in one go: start Tor & set network proxy settings automatically</a></li>\n<li><a href=\"/simple-tor-setup-on-mac-os-x/#non-standard-apps\">Non-standard apps</a></li>\n</ul>"
|
||
}
|
||
}
|