![]() ![]() ![]() -L 8000:localhost:27017 tells ssh to connect your local ( L) port 8000 to the address + port localhost:27017 on the server, in other words to MongoDB running locally on the server.-f instructs ssh to run in the background. ![]() -N instructs ssh not execute a remote command, so it won't open a remote shell on the server.-i ~/my-aws-key.pem specifies the path to the ssh private key file to use for authentication.Here's an example command that I used to create an SSH tunnel between port 8000 on my local machine and the MongoDB port 27017 on an Ubuntu server running on AWS EC2. An important detail here is that the destination address + port are accessed from the context of the server, so localhost or 127.0.0.1 refer to the server machine on the destination side of the tunnel, not your local machine.Ĭreate an SSH Tunnel to a remote MongoDB server After the data reaches the SSH server it gets forwarded to the address + port you specified when you created the SSH tunnel. To connect to a remote MongoDB server running on AWS EC2 that only allows local connections you can use an SSH tunnel, also known as SSH port forwarding.Īn SSH tunnel creates a connection between a port on your local machine and an address + port on the server, and tunnels the data to the server over SSH on port 22 so it doesn't get blocked by any firewalls or security groups (assuming SSH connections are allowed to the server). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |