X

SSH forwarding MongoDB port from remote to local

How to SSH forward MongoDB’s port from the remote machine to the local machine’s port

Consider you have a MongoDB instance running on a remote server and you want to access it without exposing it to the public. You can access it by forwarding its port through an SSH connection between your PC and your remote server.

Example

An instance of MongoDB is running on our remote server on port 21017. We will access it on localhost:21017 by SSH port forwarding.

ssh -L 27017:REMOTE_IP:27017 root@REMOTE_IP

Now, you can connect to localhost:21017 with a MongoDB client and your traffic will be forwarded to the remote machine through an SSH-opened connection.

Spread the love
Categories: How To Linux
Alin Alexandru: Hello! My name is Banuta Alexandru Alin and I am working as a full-time programmer. I have experience in data mining, data science, and data parsing/crawling. I like to travel when I have some days off. May my knowledge help you and protect your way!