SSH tunnel to a postgres database [closed]

Currently I develop on a remote dev server. I SSH into the dev server (using SSH keys) as

ssh -p 22222 [email protected]

Then from the dev server, I connect to the database over the local network

psql -U postgres -h psqldb -d my_database

where psqldb points to 10.0.0.202 on the dev server's /etc/hosts file.

I want to start developing locally on my own computer. How do I connect to the psqldb Postgres server from my local machine by using the remote dev server as an SSH tunnel (or is there a better way to do it)?

EDIT

I failed to mention that I already have Postgres installed on my local server and listening on the default port 5432.


ssh -L localhost:5432:psqldb:5432 -p 22222 [email protected]

And on another terminal:

psql -h localhost -d my_database -U postgres

Simple, safe and encrypted. I don't know a better way.