4

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?

2 Answers 2

4

Here is the solution: http://www.spencerstirling.com/computergeek/sshtunnel.html

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

1

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 [email protected]

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

ssh -p5000 localhost

You must log in to answer this question.

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