PostgreSQL SSH Tunnel
It is highly recommended that you never permit remote logins to PostgreSQL, unless you are doing it over SSL.
ssh -L 3333:foo.com:5432 joefoo.com@
psql -h localhost -p 3333 postgres
If you would like to access your PostgreSQL server remotely, it is recommended that you use a secure TCP/IP connection, which can be done over SSH.
For more information, please read the following documentation on the PostgreSQL website.