OS X: SSH tunnel in OS X Lion

Best and easiest way to secure your internet connection in untrusted network (like free Wi-Fi hotpot)?
SSH Tunnel :)

You’ll just need a shell account on a server and You’re ready to go. Fire up Terminal:

ssh -D 8080 -f -C -q -N user@yourserver.com

Legend:
-D 8080 : This basically does a lot of dynamic stuff and makes it behave as a SOCKS server. Of course you could use any non privileged port here (above 1023).
-f : This will fork the process into the background after you type your password.
-C : Turns on compression.
-q : Quiet mode. Since this is just a tunnel we can make it quiet.
-N : Tells it no commands will be sent. (the -f will complain if we don’t specify this).

Then open System Preferences -> Network.

Select active network connection, click Advanced... -> Proxies -> SOCKS Proxy.

In SOCKS Proxy Server enter localhost:8080 and You’re DONE! :)

Now You can check if Your IP Address changed in www.whatsmyip.org.

Aside

Quick Tip: Watch Me!

Very, very, very useful command!

Let’s say You want to observe the result of something being done every 5 seconds. For example list directory contents in which You’re creating backups in other thread. How to do this? Simply – use watch command:

watch -n5 'ls -lh /srv/backups'

Remember that brackets are very important and command in brackets can’t be alias (like ll for ls -l).

Mail.app: problem with IMAP synchronization

This problem occurred to me yesterday. Mail.app couldn’t synchronize with IMAP account properly. During investigation I’ve found out that it’s creating same one message in Drafts folder in a loop. After 1 day there was around 1300 messages… pretty cool, yeah? Nope, not really… Quick research and I’ve found a solution – remove Mail.app‘s offline cache. Fire up Terminal and do:

rm -rf /Users/$USER/Library/Mail/V2/[IMAP-account]/.OfflineCache

Mac OS X Lion 10.7.4