Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The issue is as follows:

I am using Ubuntu Linux.

I am working from home, and I need to access a PostgreSQL database severer within my company's network. Call the DB server X. For security reasons, only one machine can be accessed from the outside using ssh, call it Y.

So the scenario is: Home <--SSH--> Y <-----> X(DB)

I think something like SSH forwarding (configured in .ssh/config) could help with this, but I am not sure how to do this, any ideas?

share|improve this question
up vote 3 down vote accepted

Here is the solution:

It is doing SSH tunneling with forwarding through a gateway. For the above scenario, you need to issue the following command:

ssh -N -L 5555:X:5432 user@Y

Where X is the name of the database server used to address it from Y. 5555 is just some arbitrary port not being used on your home machine and 5432 is the port on which the PostgreSQL database server on X is listening. When you issue this command, you will be asked for a password, this is the one you use for logging into Y.

The PostgreSQL client (pgAdmin for example) is configured as follows: host: localhost port: 5555 username: the database username password: the database password

share|improve this answer

You can do a reverse ssh tunnel to puncture a hole through the corp firewall. Do this from within the company:

ssh -nNT -R 5000:localmachinename:22

When you're logged in you can connect from home by doing:

ssh -p5000 localhost
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .