0

I have 2 machines:

  1. my local windows PC (for this example X.X.X.X).
  2. my cloud VM with public IP (Y.Y.Y.Y).

I have a database on the VM listening to 127.0.0.1:27017.
I can only connect to my VM using ssh on port 22.

How can I forward the traffic so that I connect to the database from my PC? I know I need some tunnel but don't understand how to set it up, should the tunnel be on my PC or on the VM?

2

If you had Linux/BSD on a local vm you could use:

 ssh username@Y.Y.Y.Y -L 27017:127.0.0.1:22

On windows you can use Cygwin, or Linux Subsystem (How to install bash on windows) if you are using Windows 10. You can do this with PuTTY too, try this guide.

1
  • used it like this: ssh user@remote_host -L 27017:127.0.0.1:27017 this allowed me to connect to localhost at port 27017 and it forward the traffic to my remote host. thanks !
    – galuzan
    Sep 18 '17 at 10:09
0

SSH itself makes a tunnel and encrypt data. Try ssh remotehost -l username to login remote VM from Linux. There is Putty application in windows too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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