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?

1 Answer 1

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' 
1
  • First I wondered because it also opens a terminal in the instance.. but it works perfectly fine. Thank you very much! Commented Apr 16, 2019 at 7:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.