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
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 Answers 2


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

 ssh [email protected] -L 27017:

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.

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .