From the local machine, access the database using the available port used in step 1 (in this example, 9090). Note: In the preceding example, port 9090 is available on the local machine.Ģ. This command establishes a tunnel to port 3306 on instance2, and presents it in your local machine on port 9090. From a local machine (for example, your laptop), run the SSH command to connect to instance1, using Session Manager-based SSH. Instance2: An EC2 instance running MySQL Database on the default port 3306. Hostname = Instance id = i-0123456789abcdefa Instance1: An EC2 instance acting as a bastion host and managed by AWS Systems Manager. Example Configurations Scenario 1Ĭreate a tunnel from your local machine to access a MySQL database running on an EC2 instance using the SSM host as a bastion host. In the preceding example, 127.0.0.1 and localport translate to access targethost:destport. To test access to the tunnel on the target port created in step 1, run the following command: telnet 127.0.0.1 localport To start the SSH tunnel, run the following command: ssh -i /path/my-key-pair.pem -L localport:targethost:destportĢ. Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.ġ. To start the SSH tunnel using Session Manager, follow these steps: AWS CLI v1.16.12 or newer on your local machine. Session Manager Plugin v1.1.23 or newer on your local machine.ģ. Note: You must have the following installed to use the SSH feature:Ģ. Install the Session Manager plugin for the AWS Command Line Interface (AWS CLI)Īllow SSH connections through Session Manager and make sure that SSH connection requirements are met. PrerequisitesĬomplete the Session Manager prerequisites Note: For instructions to access your EC2 instances with a terminal or a single port forwarding using Systems Manager, see Setting up Session Manager. Ease of use: You can access resources in your private VPC directly from your local machine. Therefore, there's no need to open any inbound rule publicly. The local resource must allow inbound traffic only from the instance acting as bastion host. This allows you to use Session Manager without any inbound connections.
0 Comments
Leave a Reply. |