Accessing the PostgreSQL server over an SSH tunnel
If your server is hosting a website on the Internet and running a database system on the same machine, it is safer to disable remote network access to the database. On the other hand, you may still want to manage your databases remotely. You can do so by tunneling PostgreSQL traffic over an SSH connection.
Note
One of the most important aspects of a database system is the speed with which it can find and return the data that you ask for. Tunneling traffic over SSH will add significant overhead to this communication. This solution is great for intermittent management tasks, but not suitable as a replacement for a direct connection to your database system.
Getting ready
Before you can access the PostgreSQL server through an SSH tunnel, you will need to make sure that an allowed hosts entry exists in the pg_hba.conf
file. This entry should allow users from the loopback IP 127.0.0.1
to authenticate using MD5-encrypted passwords. Take a look at the...