Search code examples
amazon-web-servicessshssh-tunnel

How to setup SSH tunneling in AWS


I have a RDS instance with mysql database and which can only be accessed by an ec2 instance running in AWS. Now i want to access my RDS instance from local machine using SSH tunneling. I searched a lot on the net but none of the solutions worked. Can any one please tell me how to do it step by step with working solution.

Any help will be highly appreciated!

I tried to run -

ssh -i myNewKey.pem -N -L 3306:myredinstance:3306 ec2-user@myec2-instance.

mysql -u dbauser -p -h 127.0.0.1 on mysql-js utility and it gave me error. Please see below :- enter image description here


Solution

  • You can do it by setting up a ssh tunel

    ssh -i /path/to/key -N -L 3306:an_rds_endpoint:3306 user@yourserver.com
    

    Then connect locally

    mysql -u myuser -p -h 127.0.0.1