Add a new inbound rule to give access to the port 22 to the current Security Group linked to the EC2 instance.Create a new Security group and add an new inbound rule to enable SSH.If the SSH AWS EC2 instance does not have enabled SSH, you have two options : Click on the current Security Group associated to the instance to verify if SSH is enabled (must exist an Inbound rule for the port 22). Enable SSH on the EC2 instance (i-036502d24caefa34a)Ī. I will configure a SSH Tunnel to connect to a Oracle 12c database located in a EC2 instance that uses the default port 1521, If you wish you can configure other port like 5432 (default port for PostgreSQL) or 3306 (default port for MySQL)ġ. Search fiverr to find help quickly from experienced MongoDB developers.In this post I will show you how configure a SSH Tunnel using Putty to connect to a AWS EC2 Instance with CentOS release 6.9 running Oracle 12c You can follow our adventures on YouTube, Instagram and Facebook. I'm currently attempting to travel around Australia by motorcycle with my wife Tina on a pair of Royal Enfield Himalayans. Subscribe to my YouTube channel or follow me on Twitter, Facebook or GitHub to be notified when I post new content. You can also see this server setup on YouTube as part of another video tutorial which covers deploying a MEAN Stack application to AWS. kill -9 įor instructions on how to quickly setup a production ready MongoDB + Node.js server on AWS EC2 see Setup Node.js + MongoDB Production Server on Ubuntu. Then run this command to kill the process and close the SSH tunnel, replacing with the id of the actual process from the above list. Run this command to find out the id of the process for the SSH tunnel (and all other 'ssh' processes'). To close an SSH tunnel that is open in the background you can kill the background process with the command kill -9 To connect to the remote mongodb server from MongoDB Compass use the following connection string to connect through the SSH tunnel on port 8000. is the username and address to the AWS EC2 server that I used for testing.Ĭonnect Mongo Shell to remote MongoDB serverĪfter creating an SSH tunnel with the above command you can connect to the remote mongodb server as if it were running on your local machine on port 8000 like this.-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 |