Accessing Intranet Sites Remotely
Posted under Dev Best Practices, Linux articles on June 21st, 2010If you are like me, maintaining a server at home is like a hobby. There is a certain satisfaction to be able to install whatever we like without having to ask for anybody’s permission.
And sometimes thanks to our tinkering, we discover good solutions that are applicable to the task given to us at work. Think about it as giving our employers a bonus.
One of the most important rules in running a server is to never expose unnecessary information publicly. Want an example? how about an obvious one, your router’s administration application. This should never be accessible from outside of your home network for an obvious reason, obviously.
But the benefit of this approach is also its own downside. Consider the following (highly likely) case:
You need to urgently change a setting on your router, while you are not at home.
Yep, you can’t. Not without doing something extra anyways.
And that something extra is SSH tunneling. Now, there are at least two ways that I know of on how to accomplish this. For simplicity’s sake, let’s talk about one now:
If you are on a Windows machine, get yourself Putty and follow the steps on this website while replacing the forwarded port numbers with the one that you are trying to use.
http://www.cs.uu.nl/technical/services/ssh/putty/puttyfw.html
Basically, you are telling Putty to tunnel port number x from a machine within your home network to port number y on the machine where you are working on.
So in the above example, to access your router’s admin application, you can setup the tunnel from port 80 on your router’s ip-address, to let’s say port 8080 on the local machine (where you are working from).
In the UNIX world, that translates into the following:
ssh -L 8080:your_router_ip:80 your_username@your_home_server.net
After successfully loggin into your home serve remotely, you can start a browser (on the machine where you’re working on currently), then go to localhost:8080 and voila! you’ll see your router’s administration application as though you are at home.
Pretty handy, eh?