Closed dimitrid closed 7 years ago
The common approach for such cases is to establish a ssh tunnel:
nohup ssh -L 6001:127.0.0.1:5432 -N web_user@web.whatever.com -i ~/.ssh/id_rsa > /dev/null &
And then to connect to database using connection string postgresql://db_user@localhost:6001/production
Thus you are not limited to any particular tool.
Yes, it is a good point. Just nice to not have this overhead every time I connect. I can close the issue if this is the recommended workaround.
while this is a workaround, it is pain in the neck when you have 10+ DBs and constantly juggle ports etc... not to mention when the ssh freezes (e.g. when you unplug your laptop from the network) and your ssh holds the port
this is pretty much the main reason why I keep using Navicat (though SQL Tabs is so much snappier and cleaner for simple scripting)
@CzechJiri
I usually have a bash script which reestablishes the tunnels after connection got dropped. I know your pain, I have much more than 10 databases to handle and all are trough ssh tunnelling.
For the moment I can only suggest a little trick I use for tunnelled connections: since it's hard to recognise the connection by port it's possible to name a connection, if you add an alias to the end of connection string separated by 3 dashes like this:
postgresql://db_user@localhost:6001/production --- PRODUCTION
Also I reopen the issue. So it waits for the proper time. As a draft highlevel design I propose to use a pipeline to make a tunnelled connections:
ssh://sshuser@sshhost:ssport?identity_file=~/.ssh/id_rsa | postgres://pguser@localhost:5432/dbname
Comments are welcome
nice trick with the alias, like it a lot
I use ruby ssh gateway library, never used JS library. From the first glance looks simple https://github.com/Finanzchef24-GmbH/tunnel-ssh
released with v0.14
It is common for production DBs to not be open to outside connections. Normally, this is handled by SSHing into a server which can connect to the DB and then proxying through that way. Would be really useful for SQLTabs to support this.
For example, see this screenshot taken from another PG GUI: