1

I am trying to follow this guide to setup a ssh tunnel to my rds database.

In particular 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.

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?

2

Yes.

As you've seen, the documentation is not very clear about it, but when you use the -e or --custom flag, you must also provide the -i flag to the underlying ssh command or it won't use the right key.

So the full command would look like this (e.g. to tunnel port 9229):

   eb ssh --custom 'ssh -i ~/.ssh/keyfile.pem -L 9229:localhost:9229'
  • First I wondered because it also opens a terminal in the instance.. but it works perfectly fine. Thank you very much! – ohlr Apr 16 '19 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.