Hi,

Am 11.05.2010 21:31, schrieb Jing Tian:
 > I need to connect to the postgresql database on a remote host.
 > The host need authentication as well as the database.
 > [...]
 >
 > I can do the ssh to connect to the host
 >
 > Net::SSH.start('192.168.0.116', hostName,:port=>8022,
 > :password=>hostPass)
 >
 > But I don't know how to continue and get connect with the database on
 > the host. The closest way I can think of is:
 >
 > conn =
 > PGconn.connect('192.168.0.116',8022,'','','databaseName', 
 >'userName','userPass')
 >
 > The error I was getting is:
 >
 > `initialize': SSL error: wrong version number (PGError)
 > expected authentication request from server, but received S
 >
 > Does anyone have the same problem. I would appreciate any inputs.
 > Thanks a lot!!

It seems sshd is listening on port 8022. On which port is postgresql 
listening?

If postgresql is listening on some local port only bound to the host 
itself (127.0.0.1), then you can tunnel your PGconn through SSH.

Open a SSH tunnel on your local machine: e.g.
ssh -p 8022 -N -v -L 
<localpostgres-port>:urgewalten.de:<localpostgres-port> user@host

then you can open a postgresql connection to 
localhost:<localpostgres-port> and it will be forwarded to your 
destination host.

Greetings,

Waldemar