How to connect to remote Postgres DB through ssh tunnel
Open a SSH tunnel on your local machine. Here I’m openning a tunnel on my local port 5555, mapping it to the remote 5432 default port of Postgres.
If you have already changed the default port of Postgres, change it accordingly here as well
ssh -fNg -L 5555:localhost:5432 username@host
I’m going to use
pgAdmin 3 app to connect to Postgres db. Just follow the new connection instruction as you’re connecting a local database.
If you’re using IDENT authentication, your local username has to be matched with the username you’re trying to log on to. Either switch to PASSWORD authentication or create a new username on remote db that match your local username as below and you’re good to go.
CREATE USER myuser; ALTER USER myuser WITH PASSWORD 'password'; ALTER USER myuser WITH CREATEUSER CREATEDB;