Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm playing with MongoDB. I have a good deal of experience with MySQL and was using something called Sequel Pro to connect to remote databases. I'm now trying MongoHub but can't seem to get it to connect to the remote database.

I tried a basic SSH tunnel

ssh -f user@remotehost.com -L 9009:remotehost.com:27017 -N

But this didn't work. How do other DB management tools use a ssh login to provide a connection to the database that doesn't have an open port? Is this something I could setup by myself (via a tunnel or something else)?

share|improve this question
    
To talk to anything past a firewall you need an open port, what do you mean by something that doesn't have an open port? –  jer.salamon Jun 23 '10 at 16:55
    
What connection string are you using to connect to the database? Can you connect to it with the command line mongo client? Can you telnet to localhost 9009? –  Justin Dearing Sep 1 '10 at 18:09

1 Answer 1

up vote 5 down vote accepted

Here's what I do to get to my remotely mysql server (I've got mysql restricted to localhost only):

ssh -fNL 9999:localhost:3306 myuser@myremotemachine

To describe it,

  • -f puts it in the background
  • -N tells ssh there is no command to execute
  • -L 9999:localhost:3306 tells to bind the local port 9999 to 3306 remotely.

Then I use MySQL Query browser and tell it to connect to 127.0.0.1 port 9999

So I suppose you could try:

ssh -fNL 9009:localhost:27017 myuser@myremotemachine
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.