Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

up vote 2 down vote accepted

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

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 username@corpserver.com

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

ssh -p5000 localhost
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.