psql tunneling thru a middle server

Started by jkellsalmost 15 years ago2 messagesgeneral
Jump to latest
#1jkells
jtkells@verizon.net

Im trying to connect my WS to a postgresql database (destination) via
a middle server
I.e.
WS ----> Middle ----> Database
server server
172.x.2.4 172.x.4.12

I can create a SSH tunnel from my WS to the middle server but not sure
how or if I can make the middle server pass connections to and from my
ws and database. BTW, they run the DB on a non standard postrgres
port. Any help would be appreciated....
Thanks

#2Rick Chu
pygator@gmail.com
In reply to: jkells (#1)
Re: psql tunneling thru a middle server

On Thu, 2011-05-05 at 15:05 -0400, jtkells@verizon.net wrote:

Im trying to connect my WS to a postgresql database (destination) via
a middle server
I.e.
WS ----> Middle ----> Database
server server
172.x.2.4 172.x.4.12

I can create a SSH tunnel from my WS to the middle server but not sure
how or if I can make the middle server pass connections to and from my
ws and database. BTW, they run the DB on a non standard postrgres
port. Any help would be appreciated....
Thanks

1. From your WS open two terminal(ssh) windows.

2. From Terminal#1 startup the ssh tunnel using:
ssh -L 5432:database.com:8432 you12@middle.com -p 20

3. From Terminal#2 connect to the database via the tunnel:
psql -p 5432 mydatabasename -U you12 -h localhost

RickC