Here's my setup -

I have two VPS ( linodes ). Linode1 has MongoDB on it. I need to access this MongoDB from Linode2. But, I don't want other users on the private network sneak my data, so I need to use autossh.

I ran autossh -M 5122 -N -R 27017:linode1ip:27017 linode1ip on Linode2 but then I am prompted to enter password for root@linode1ip.

What I expect is, when I successfully execute (after modification) the above command, I can connect to mongo from Linode2 simply using mongo 127.0.0.1:27017. Am I wrong about this assumption?

Thank you,all.

link|improve this question

feedback

2 Answers

up vote 0 down vote accepted

The second -M in your command isn't required and will (if the command line you have posted is correct) cause you to get a Bad remote forwarding specification 'linode1ip'

The command that you want to setup the tunnel is

autossh -M 20000 -N -p 22 USER@LINODE1IP -L 27017/localhost/27017 (edited)

This will setup an ssh tunnel between localhost:27017 on linode2 and port 27107 on linode1.

If you want to get this setup without having to provide a password you will have to setup public key authentication and ssh-agent.

link|improve this answer
That was a typo. – KPL Mar 31 '11 at 19:15
I setup public key auth and tried the command, no luck. – KPL Apr 1 '11 at 6:00
Thanks. I updated the answer with the command that worked. – KPL Apr 1 '11 at 6:18
feedback

What I understand is that you need a way to exclude the password prompt from your setup? If is it what you want, you need to setup public-key authentication. That way you can pretty much fire-and-forget the connection.

Key authentication for root user is kinda of risky, so maybe you want to use your tunnel as the mongodb user or other non-privileged user.

I am not sure of that autossh line, but I never really used the tool. Maybe you should try to get a tunnel running using ssh first and then add the autossh part after all problems are sorted out.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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