By using AWS re:Post, you agree to the Terms of Use

EB-Cli SSH Tunnel to RDS Database


I am trying to follow this to setup a ssh tunnel to my rds database via a ec2 instance managed by beanstalk.

In particular I want to use this command:

ssh -N -L localPort:rdsHost:remotePort user@remoteHost -i ~/path/to/key

However, I am using aws-elastic-beanstalk with the eb-cli.

The eb cli provides eb -ssh to connect via ssh to an instance.
So I tried to achive the same with:

eb ssh -e '-N -L localPort:rdsHost:remotePort'

from the eb documentation:

-e CUSTOM, --custom CUSTOM
Specify an SSH command to use instead of 'ssh -i
keyfile'. Do not include the remote user and hostname.

However, this only yields the following output and terminates instead of creating a tunnel.

INFO: Attempting to open port 22.
INFO: SSH port 22 open.
INFO: Running -N -L localPort:rdsHost:remotePort ec2-user@ip-of-instance

Is it possible to create a tunnel with the eb-cli?

asked 4 years ago58 views
3 Answers

RDS does not support ssh to a RDS host.

answered 4 years ago

Hello Phil,

I'm not talking about direct ssh access but via a tunnel from an ec2 instance managed by beanstalk with the eb-cli.

And yes, it is possible:
Here the solution is given, maybe you should consider updating the documentation of the eb-cli.

Best regards

answered 3 years ago

As Phil said, you can’t SSH into an RDS host. You can port forward using SSH Tunneling via an EC2 host as an alternative to opening up an internet-accessible port to your RDS instance. In that case RDS isn’t participating in SSH at all it just sees a normal connect on its regular port from within the VPC.

Although I’ve never tried to follow the instructions, here is another good article on using SSH Tunneling to connect to RDS

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions