dblab icon indicating copy to clipboard operation
dblab copied to clipboard

[FEATURE] SSH tunnel support

Open mhammerly opened this issue 1 year ago • 6 comments

Most databases I want to connect to are only reachable with an SSH tunnel through a bastion server. Some database clients (DBeaver, DataGrip, pgcli off the top of my head) support setting up tunnels in their config and it'd be nice if dblab did as well.

mhammerly avatar Jun 07 '24 16:06 mhammerly

+1 to this. I make use of SequelAce usually but I'd love to have DBLab as an alternative for when I'm in a terminal scenario and don't have a GUI. I was just reviewing all the docs to see if this was supported and can't find any mention of "proxy" "tunnel" or "ssh".

drakythe avatar Jun 07 '24 16:06 drakythe

@mhammerly Thanks for bringing this to my attention. Can't promise to work on this right away, because I have other issues with higher priority, but I've been doing my best to address users' requests lately.

danvergara avatar Jun 07 '24 17:06 danvergara

whenever you get around to it (if you can at all), thanks! just made an issue to give myself and others a place to subscribe

dblab looks cool, may write a little wrapper script so i can try it out in the meantime!

mhammerly avatar Jun 07 '24 20:06 mhammerly

Really looking forward to have SSH tunneling built in 👍

I am not a golang developer, but I could have a look into this. Would only need to know if there is a good package for it 😉

janpieper avatar Jun 12 '24 07:06 janpieper

DBLAB looks really cool. I am really looking forward to have this built in as well 👍🏽

grindarius avatar Jun 20 '24 09:06 grindarius

This library should make it easy to add SSH tunneling to DB connections:

  • https://github.com/jfcote87/sshdb

hsanson avatar Jul 05 '24 05:07 hsanson

Guys, there's a new PR addressing this issue. Please, check it out and let me know if that satisfies your requirements. Sorry if it took so long to arrive.

danvergara avatar Jan 04 '25 23:01 danvergara

@danvergara thank you!

i'm able to connect to my database with this feature using the command below and it populates the list of tables, but if i try to run a query or select a table the results window shows an error: read tcp 10.1.1.1:49332->10.2.2.2:22: use of closed network connection

dblab \
    --host <redacted> --port 5432 --driver postgres --db postgres --user matt --pass '<redacted>' \
    --ssh-host <redacted> --ssh-user matt --ssh-port 22

i don't know golang but from a quick skim of the PR it looks like the SSH connection may be allowed to close after initial startup? https://github.com/danvergara/dblab/pull/246/files#r1904690197

mhammerly avatar Jan 06 '25 22:01 mhammerly

@danvergara thank you!

i'm able to connect to my database with this feature using the command below and it populates the list of tables, but if i try to run a query or select a table the results window shows an error: read tcp 10.1.1.1:49332->10.2.2.2:22: use of closed network connection

dblab \
    --host <redacted> --port 5432 --driver postgres --db postgres --user matt --pass '<redacted>' \
    --ssh-host <redacted> --ssh-user matt --ssh-port 22

i don't know golang but from a quick skim of the PR it looks like the SSH connection may be allowed to close after initial startup? https://github.com/danvergara/dblab/pull/246/files#r1904690197

Thanks @mhammerly for bringing this to my attention. I put out a new PR to address this issue. Please, check it out.

danvergara avatar Jan 06 '25 23:01 danvergara

@mhammerly just merged #249 and released v0.30.1 fixing the bug.

danvergara avatar Jan 07 '25 04:01 danvergara