Question

Can't connect to remote Postgres DB Using PGAdmin III via SSH Tunnelling

Posted March 27, 2016 8.1k views
PostgreSQLLinux Commands

I am trying to connect remotely to a PostgreSQL DB using PGAdmin III

FYI I am using SSH Keys to connect to my instance, no passwords.

I have setup the SSH tunnel like so:

ssh -L 3333:remote.server.com:5432 myuser@remote.server.com

Then in the postgresql.conf I have modified the listening addresses to: listen_addresses='*'

Just in case, I also added to pg_hba.conf the line :
host all all 0.0.0.0/0 md5 however I still get the same error so I believe this is useless.

Finally in PGAdmin, I create new connection using
host: localhost
port: 3333 (as per local tunnel option above)
username: myuser
Then on SSH tunnel tab, I have a checkmark on use SSH tunneling
tunnel host: remote.server.com
tunnel post: 5432
username: myuser
identityfile: I point to my local idrsa.pub file
and I enter my passphrase.

I get the following error:
SSH error: Error when starting up SSH session with error code -13

I added the -v option to the SSH tunnel creation line and I see “authentication successful” as well as “local forwarding listening on 127.0.0.1 port 3333”

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

You need to point to your local idrsa file (the private key file).

Submit an Answer