<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ERWIN.co &#187; Mac OS X</title>
	<atom:link href="http://erwin.co/tag/mac-os-x/feed/" rel="self" type="application/rss+xml" />
	<link>http://erwin.co</link>
	<description>thoroughly chinafied american business geek in shanghai</description>
	<lastBuildDate>Wed, 04 Jan 2012 05:31:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using SSH to bypass The Great Firewall/GFW</title>
		<link>http://erwin.co/2009/12/09/using-ssh-to-bypass-the-great-firewallgfw/</link>
		<comments>http://erwin.co/2009/12/09/using-ssh-to-bypass-the-great-firewallgfw/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 09:13:14 +0000</pubDate>
		<dc:creator>Erwin</dc:creator>
				<category><![CDATA[Uncategorized (无大类）]]></category>
		<category><![CDATA[China (中国）]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://erwin.co/2009/12/09/using-ssh-to-bypass-the-great-firewallgfw/</guid>
		<description><![CDATA[This looks like a long process, how does it work after I’m done? You’re ssh tunnel to your server outside the GFW will be active *whenever* your online When you need to bypass the GFW, simply select “SSH” from your locations menu When you don’t need to use your proxy, simply switch your location back [...]]]></description>
			<content:encoded><![CDATA[<p>This looks like a long process, how does it work after I’m done?<br /></p>

<ul>
  <li>You’re ssh tunnel to your server outside the GFW will be active *whenever* your online</li>

  <li>When you need to bypass the GFW, simply select “SSH” from your locations menu</li>

  <li>When you don’t need to use your proxy, simply switch your location back to Automatic</li>
</ul>

<p>What you need:</p>

<ul>
  <li>SSH access to a server outside the GFW (See: <a href="http://www.serverage.com/">ServerAge in Hong Kong</a>)</li>

  <li>SSH Key Authentication configured (See: <a href="http://sial.org/howto/openssh/publickey-auth/">ssh-keygen, id_pub.rsa and ~/.ssh/authorized_keys</a>)</li>

  <li>AutoSSH to auto-restart SSH sessions and keep SSH on forever (See: OS X Binary or <a href="http://www.harding.motd.ca/autossh/">Source</a>)</li>

  <li>Instructions assume your on Mac OS X, but can be applied to any version of Linux</li>
</ul>

<p>Configuring SSH key based authentication can be very difficult if you haven’t configured it previously. The idea is:</p>

<ul>
  <li>Generate a key set on your local computer (with ssh-keygen on the local system)</li>

  <li>The Key Set will make two files on your hard drive, a “Private Key” and a “Public Key” (~/.ssh/id_rsa.pub on the local system)</li>

  <li>Note that the “Private Key” is many “lines” long, but the “Public Key” is a single line (no newlines/returns)</li>

  <li>The server that you’re logging into keeps a list of keys that are authorized to access the system (in ~/.ssh/authorized_keys on the server)</li>

  <li>Copy the single line of your “public key” file onto any line of your “authorized keys” file.</li>

  <li>Make sure the permissions of both your public keys and private keys are “correct”. “Insecure” file permissions are the most common cause of SSH key’s failing to authenticate.</li>

  <li>Always keep your .ssh dir and all your keys chmodded to 700 and 600 respectively.</li>

  <li>Use “ssh -vvv” if you have trouble logging in, this will give you diagnostic output.</li>
</ul>

<p>Verify that you’re able to connect to the system you’ll be using to proxy via SSH.</p>

<p>If you’ve got the Apple Developer Tools installed, then go directly to the AutoSSH website, download the source, compile and install. In case you don’t, I’ve complied a copy that you can download here.</p>

<p>Just extract with:
[shell]tar zxvf autossh.tgz -C /[/shell]</p>

<p>Use foreground mode to verify that you’re able to connect to the system of your choice via AutoSSH.</p>

<p>[shell]autossh -M 19999 -D 9999 -N example.com[/shell]</p>

<p>Use cURL to verify that your proxy is working</p>

<p>[shell]curl —socks4a localhost:9999 -v www.facebook.com[/shell]</p>

<p>Now that your proxy is online, the next step is to define a new location in your Mac OS X “Network” Profiles.</p>

<p>In System Preferences / Network:</p>

<ul>
  <li>From the Locations dropdown choose “Edit Locations” then add a new location called “SSH”<br />
  <img src="http://erwin.co/wp-content/uploads/2009/12/Screen-shot-2009-12-01-at-上午01.07.36.png" width="300" height="126" alt="Screen shot 2009-12-01 at 上午01.07.36.png" /></li>

  <li>Return to the main Network window and choose “Advanced” then “Proxies”<br />
  <img src="http://erwin.co/wp-content/uploads/2009/12/Screen-shot-2009-12-01-at-上午01.07.28.png" width="304" height="258" alt="Screen shot 2009-12-01 at 上午01.07.28.png" /></li>

  <li>Enable “SOCKS Proxy” setting the proxy server to “localhost” and port “9999”<br />
  <img src="http://erwin.co/wp-content/uploads/2009/12/Screen-shot-2009-12-01-at-上午01.08.09.png" width="480" height="375" alt="Screen shot 2009-12-01 at 上午01.08.09.png" /></li>

  <li>Under bypass proxy setting for these hosts and domains, you can enter any sites that will be slowed down by proxing via your SSH connection:<br />
  [plain]*.local, 169.254/16, *.cn, *.163.com, *.baidu.com, *.youku.com, *.toudou.com, *.sina.com, *.chinesepod.com[/plain]</li>
</ul>

<p>Last, we just need to configure autossh to start when our Mac boots up. We’ll use a Login Hook so that the script will run regardless of which user logs in.<br /></p>

<p>http://support.apple.com/kb/HT2420</p>

<p>You’ll need to create the shell script to use as the Login Hook, save it as /usr/local/bin/loginhook, and make it executable (chmod 755).</p>

<p>[shell]
    #! /bin/bash</p>

<pre><code>if [ &amp;quot;$(ps ax | grep autossh | grep -vc grep)&amp;quot; -lt 1 ]; then
  sudo -u {USER} /usr/local/bin/autossh -f -M 19999 -D 9999 -N -o ServerAliveInterval=3 {SERVER}
fi
</code></pre>

<p>[/shell]</p>

<p>If you have trouble connecting and need to debug the autossh line, first try disabling the &#8220;-f&#8221; so that the program runs in the foreground and returns output. If you need to send the output to a log file, you can edit the loginhook script to something like:</p>

<p>[shell]sudo -u {USER} autossh -M 19999 -D 9999 -N {SERVER} 2&amp;amp;&gt;1 &amp;gt;&amp;gt; /tmp/loginhook.log[/shell]</p>

<p>(Note that you’ll need to replace {USER} with the short name of the user account that is providing the SSH public key and {SERVER} with the host your connecting to)</p>

<p>[shell]sudo defaults write com.apple.loginwindow LoginHook /usr/local/bin/loginhook[/shell]<br /></p>

<p>If your ever in doubt as to weather or not your new Proxy is running correctly, save the following script as /usr/local/bin/gfw. Run this script to instantly check on the status of your proxy.</p>

<p>[shell]curl &#8211;socks4a localhost:9999 -v www.facebook.com[/shell]</p>

<p>Reboot, Test and Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://erwin.co/2009/12/09/using-ssh-to-bypass-the-great-firewallgfw/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Languages in Snow Leopard (Finder Info Window)</title>
		<link>http://erwin.co/2009/09/15/snow-leopard-select-language/</link>
		<comments>http://erwin.co/2009/09/15/snow-leopard-select-language/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 17:17:04 +0000</pubDate>
		<dc:creator>Erwin</dc:creator>
				<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://erwin.co/2009/09/15/snow-leopard-select-language/</guid>
		<description><![CDATA[In Mac OS X Leopard (10.5) and earlier, the Finder &#8220;Info&#8221; window for an application would allow you to enable and disable specific language packs. This was probably one of the least frequently features of the finder for average users, and so it was removed in Snow Leopard. Unfortunately, I used that feature all the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://erwin.co/wp-content/uploads/2009/09/200909160112.jpg" width="259" height="125" alt="200909160112.jpg" style="float:left; margin-right:8px;" />In Mac OS X Leopard (10.5) and earlier, the Finder &#8220;Info&#8221; window for an application would allow you to enable and disable specific language packs. This was probably one of the least frequently features of the finder for average users, and so it was removed in Snow Leopard.</p>

<p>Unfortunately, I used that feature all the time <img src='http://erwin.co/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Primarily to disable the horrendous Chinese localization (halfway done) that is Adium. For me, reading Chinese is easy and reading english is even easier. But when a set of menus is half Chinese/half english, then my eye just automatically skips over the Chinese part, skipping to the english part I can read without even thinking&#8230;</p>

<p>There is a FREE utility that you can download to get this functionality back. It&#8217;s called &#8220;<a href="http://www.tj-hd.co.uk/en-gb/languageswitcher/">Language Switcher</a>&#8220;. Language Switcher will even allow you to launch two instances of an application, both in different languages. Take a look!</p>

<p><img src="http://erwin.co/wp-content/uploads/2009/09/200909160115.jpg" width="420" height="223" alt="200909160115.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://erwin.co/2009/09/15/snow-leopard-select-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

