postgresql - Connecting to database through ssh tunnel -


our production databases accessible production application servers. able login production app servers , psql db, setup ssh tunnel allow me access production db work box.

ideally, single command run workbox set tunnel/proxy on production app server

here have come with, doesnt work.

user@workbox $ ssh -fnt -l 55555:db.projectx.company.com:5432 app.projectx.company.com user@workbox $ psql -h app.projectx.company.com -p 55555  psql: not connect server: no route host server running on host "app.projectx.company.com" (10.1.1.55) , accepting tcp/ip connections on port 55555? 

the reported ip address incorrect.

when connecting tunnel endpoint, hostname local host, since that's forwarded port exposed.

ssh -fnt -l 55555:db.projectx.company.com:5432 app.projectx.company.com psql -h localhost -p 55555 

btw, pgadmin-iii provides ssh tunnel automation. on other hand, it's big gui app without psql's handy \commands.

it's pretty trivial write sshpsql bash script fires ssh tunnel, stores pid of ssh process, launches psql, lets want, , on exit kills ssh tunnel. you'll want trap "kill $sshpid" exit kill tunnel on unclean exits.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -