I'm new to ssh tunneling. I'm trying to access a database from developer machine, which is accessible only from my production server.

I am able to open an SSH connection to the production server from the developer machine, but I don't know how to tunnel the remote database port using production server to developer machine.

I have tried the following with no success

ssh -L 9999:remote_database:5432 user@production_server

Any hint is appreciated.

  • The database runs on port 5432 remotely and you want it on 9999 locally? remote_database is the name of a server which is reachable over telnet to that port on production_server? – tripleee Jun 16 '17 at 15:37
  • Yes exactly. Database is running on the a machine which is different from prod and dev server. Its accessible only from the prod server on port 5432, so If I wanted to open a connection to it from prod I would use remote_database:5432. Now I want to access Database from the dev machine on port 9999 locally by tunneling with SSH. – 11thdimension Jun 16 '17 at 15:51
  • use the IP address or remote database in lieu of the name – Rui F Ribeiro Jun 16 '17 at 16:03
  • Try it!! Give it a -v flag to make some more noise! Try to connect to port 9999 on your machine and tell us what happens! – quadruplebucky Jun 16 '17 at 16:03
  • Still same, port 9999 is open on the dev machine after running ssh tunnel command ssh -L ... however when I try to connect to it waits and shows error connection timed out. – 11thdimension Jun 16 '17 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.