In this post, we will learn how to configure MongoDB Compass (running on windows) to connect to remote MongoDB on Centos.


1. Linux Enabled on Windows 10. Check out here...


Putty Installed

2. MongoDB Compass Installed

Set up SSH Tunnel on Windows to Remote MongoDB Centos server

Below commands would assume, you have bash shell accessible in Windows.

ssh -L 9999:localhost:27017 [email protected]_host_ip

The above command will create a tunnel. By doing above we have MongoDB accessible at localhost:9999.

Setup SSH Tunnel Using Proxy

If you are behind firewall, then you will have to provide the proxy server settings as shown below...

export SOCKS5_SERVER='<proxy_host_name>:<proxy_port>'
export ssh_proxy='ProxyCommand=connect -s %h %p'
alias ssh='ssh -o "$ssh_proxy" $1'

Add the above commands in the ~/.bashrc so that you dont have to type again in new terminal.

Now we can create our tunnel using same command...

ssh -L 9999:localhost:27017 [email protected]_host_ip

Configure MongoDB Compass

Start MongoDB Compass and enter following and hit "connect"

If there is no error, you would see DBs from remote mongoDB server in MongoDB Compass.