Robomongo connect to AWS EC2 behind ssl redirect/tunnel

A client of mine has a few EC2 instances that I manage. One of them I installed an SSL Cert on, and all http traffic is forwarded to https.

The Mongodb instance is bound to, but I found no way to get Robomongo to connect. Instead, I set up an SSH port forwarding where my local mac listens on port 5555, and passes though (tunnels) the remote server’s port 27017 traffic as a background process. The set up is simple, and may really help someone out, so I’m putting it here:

In the terminal, type in the following all as a single line of input (except the dollar sign which I’m using to indicate terminal prompt):

ssh -fN -i /users/me/.ssh/my.pem -L 5555:localhost:27017

Now, open Robomongo and create a new connection.

In the “Connection Settings” dialog:

Pick your Name: and enter it.
For “Address”: enter ‘localhost’ (without the single quotes)
After the colon, enter ‘5555’ (without the single quotes)

So, your dialog should look something like this:

That’s all you need to fill in! You don’t need to mess with any of the other tabs. Now, press the “TEST” button. You should be good to go.

Later, if you want to get rid of the process enter the following at the command line:

$ lsof -i :5555

It will give you the process id of your tunnel. To get rid of it, lets say the process id was 4412:

$ kill -9 4412

That’s it. You’re done.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s