Monday, May 23, 2011

Connecting to a Mac from an iPhone over 3G

A couple hours ago I realized I may need to connect to my Hackintosh this weekend while I'm out of town. Turns out, there are some really cool tools to do this securely for only $2! It took me a bit more than an hour to set up, so I thought I'd write an entry for future reference.

In this tutorial, I'll be setting up both VNC and SSH on OSX 10.6 and connecting to it over 3G using an iPhone 3GS. 

The first thing you need to do, is set up a VNC server. There are a number of free VNC servers for OSX that you can download, and I chose to go with Vine Server. You can use the default configurations and simply start the server.

Next, you'll need to open up a port on your router so that incoming requests won't be rejected. The standard port for SSH is 22. I followed this tutorial for opening up my port. Basically, all I had to do was:

  1. Open up my router's control panel by typing http://192.168.1.1/ into my address bar. If you don't know your router's default password like me, you can look it up here.
  2. Find the section in the settings where you can add port forwarding, and for the port put 22 and for the IP address, use the internal IP address of your machine that the VNC server displays. This will be something like 192.168.1.101. If you can't find the settings for port forwarding, this port forwarding tutorial site has good instructions for a number of routers.
Now that the router is forwarding external requests to your Mac, you need to allow SSH access to your Mac. To do this, you can go into System Preferences and enable "Remote Login".
Your Mac is now set up for accepting SSH connections on port 22, and someone who has tunnelled in can then connect to the VNC server on port 5900. Here is how to actually do this:
  1. Download an iPhone VNC client app such as Remoter VNC. This one costs $1 for basic VNC connections and has an additional $1 addon for SSH connections.
  2. For the SSH hostname, enter the IP address of your home computer. If you don't know this, just go to http://www.whatsmyip.org/ and it will tell you.
  3. For the SSH username and password, use the username and password for your Mac.
  4. For the VNC hostname, enter the internal IP address of your home computer. This is the one that looks something like 192.168.1.101.
  5. For the VNC port, enter 5900.
  6. If you set up a VNC password, be sure to enter that as well.
After all that, you should be able to have full access to your home computer through a secure connection no matter where you are! It's a big relief for me knowing I can access my stuff while I'm away this weekend.