Use Putty to connect “locally” to your Amazon EC2 server through your browser

First of all, if you are looking for shell access to your EC2 server, then it will be just as simple to follow Amazons Putty instructions here. This post assumes you have already set up an EC2 instance (including the *optional* puttygen section)and have connected to your server shell via putty already.

This post will focus on making a “local network” connection to your EC2 server so that you can connect to it with your web browser via a SOCKS proxy.  You would do this so you don’t have to open up additional ports in order to administer your server and it is good practice to minimize the number of ports you are exposing to the interwebs.   If you wanted to administer Glassfish via the GUI, for example, you would want to attach to your server on port 4848 in your browser. This is how you would do that.

Let’s get started!

1) First of all we will modify our existing putty connection to our EC2 instance (I have obfuscated my ip with an arbitrary 111.222 postfix)

2) Now expand  Connection -> SSH and select Tunnels. Enter a Source Port number (this can be any number you like), then select the Dynamic radio button as well as the Auto radio button and then click the Add button.
You may want to go back to the session screen from #1 and Save your changes at this point.PuTTYPortForwardSettings2

3) Open up your Browser. I have chosen Firefox as it is easily configurable without making system wide Proxy changes.  Open up your connection settings (in Firefox it is under Tools -> Options -> Network Tab -> Settings Button). Select the Manual proxy configuration radio button and enter into the SOCKS host, and enter the port number you chose in #2 into the port. Click Ok.

4) Log into your Amazon console (in a different browser like Chrome) and take note of the “Private IPs” ip address. In this case I have again replaced the postfix with the arbitrary 111.222.AWS-EC2Console5) Go back to putty and open the connection to your EC2 instance. Once the connection is established you can switch back to your browser and attach to that Private IP as though it was a server on your own internal network.glassfishConsole

Keep in mind that your (Firefox) browser will now be using the proxy server and you will not be able to visit sites other than those available through the proxy. This is simply a quick way to start administering your server on ports that are not accessible by default.

There are many ways to skin this cat, however. You could open ports on your server (ill advised), exercise your 1337 skills in VI to alter config on the server so a GUI is never required, or you could even set up a permanent proxy via a local apache server and v-host config.  Hopefully this will be enough to get you off the ground so you can explore other options at your liesure.


Leave a Reply

Post Navigation