The most secure way to do this is probably to configure an SSH tunnel. It will securely send traffic from the Droplet to your local machine without needing to expose the database publically.
Assuming you already have SSH set up, from your local machine run:
ssh -L 63333:localhost:5432 firstname.lastname@example.org
Let’s break that command down a bit:
63333 is the port you want to be able to access Postgresql on locally. It doesn’t need to be that number, it is just for example.
5432 is the port that Postgresql is running on the Droplet. That is the default port used.
Now when you set up PgAdmin, you can use
localhost for the “Host” setting and
63333 for the port.
For more information on how SSH tunneling works, check out:
In this article, you'll learn how to create a safe, encrypted tunnel between your computer and your VPS along with how to bypass limits in a corporate network, how to bypass NAT, etc.