dbeaver icon indicating copy to clipboard operation
dbeaver copied to clipboard

Native SSH tunnel over AWS SSM

Open ghost opened this issue 5 years ago • 13 comments

Is your feature request related to a problem? Please describe. Currently, I'm connecting to my RDS instances through jump hosts over AWS SSM. Since there's no AWS SSM support yet on dbeaver, I'm creating the SSH tunnel separately on terminal, and then on my dbeaver connection settings, I connect to the databases on localhost. This is far less than ideal and not scalable when working with multiple databases and drivers.

Describe the solution you'd like I would like a native support for SSH tunnel over AWS SSM.

Describe alternatives you've considered Perhaps having dbeaver to read from local ssh config? That way we could still make use of ProxyCommand to invoke aws ssm to start a session.

ghost avatar Jun 25 '20 21:06 ghost

thanks for suggestion

uslss avatar Jun 26 '20 09:06 uslss

The solution to this doesn't need to be as complex as supporting AWS SSM. SSM already supports SSH, so all DBeaver needs to do is allow the use of the native SSH agent. On macOS for example my ~/.ssh/config is all setup and working for SSH to proxy via SSM, so if DBeaver used that everything would just work. Alas, unfortunately it doesn't.

ghost avatar Jun 24 '21 14:06 ghost

Very interested also :)

I am very interested in the AWS SSM feature.

vrcollins avatar Dec 16 '21 20:12 vrcollins

DBeaver using the system-wide SSH setup would benefit from all the SSH tooling (ssh-agent, ssh_config, known_hosts, etc) and the feature here requested would be available for free.

I am lacking some context on why DBeaver uses its own separate SSH stack. I'd be interested in the topic if anyone can share some links.

n1ngu avatar May 06 '22 10:05 n1ngu

Will add, that AWS SSM SSH tunnel, also, makes possibe to connect to DBs that located in private subnets with no need to create bastion host in public. So yes - we are waiting for this feature too

bober2000 avatar May 31 '22 15:05 bober2000

Any updates?

ArturV93 avatar Nov 14 '22 12:11 ArturV93

This feature would indeed be great

chaodhib avatar Nov 29 '22 17:11 chaodhib

You can use your existing SSH config for SSM just fine with DBeaver, simply open an SSH tunnel with the proper ports:

ssh [SSM-PROFILE-NAME] -L 5432:[RDS_SERVER_ADDRESS_IN_AWS_PRIVATE_SUBNET]:5432

Then connect to your localhost port 5432 to access your AWS RDS instance behind SSM

bm-jacob avatar Mar 09 '23 16:03 bm-jacob

simply open an SSH tunnel with the proper ports

@bm-jacob Obviously you can do that. We are speaking about using SSM within network profiles manged by DBeaver.

n1ngu avatar Mar 09 '23 16:03 n1ngu

Although you can't use SSM or EC2 Instance Connect in the SSH tab, you can use Shell Commands to setup SSM or EC2 Instance Connect and then tunnel through that. With this the entire connection will be handled within DBeaver, but managing this through the SSH tab directly would be greatly preferable. For instance, this workaround probably works best with unique ports for tunnels to different instances and every instance is identified as localhost so you either have to select Bypass host verification (under Advanced settings on the SSH tab) or manually check the host every time you connect to a different instance.

image

image

Fydon avatar Sep 05 '23 08:09 Fydon

Here is how ive got it done without using "Before Connect" shell script and instead manually doing shell yourself:

  1. Step 1 (shell) = SSO Login via shell (assuming sso profile already configured): aws sso login --profile {loremIpsumProfile}

  2. Step 2 (shell) = Create a remote host tunnel via same shell you logged in at step 1: aws ssm start-session --target {loremIpsumTarget} --profile {loremIpsumProfile} --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"portNumber":["22"],"localPortNumber":["9999"],"host":["loremIpsumHost"]}'

  3. Step 3 (dbeaver) = SSH into the tunnel via dbeaver. For this, use localhost and 9999 in the ssh tab.

Rah1x avatar Feb 05 '24 04:02 Rah1x

As a follow up to my previous comment, to get around needing to use bypass host verification enter a unique host name for each instance that maps to 127.0.0.1. This can either be performed in the hosts file or by using a service that maps DNS names to IP addresses, e.g. db.127-0-0-1.nip.io.

Fydon avatar Feb 05 '24 09:02 Fydon

Native AWS SSM tunnels support will be added in DBeaver 24.1 (PRO products). Unfortunately it is not possible to add this feature in Community (one of the reasons is dependency on AWS SDK and AWS CLI).

serge-rider avatar May 13 '24 15:05 serge-rider