To close the port 5432 for any traffic or don’t want to configure PostgreSQL to listen to any remote traffic, use SSH Tunneling to make a remote connection to the PostgreSQL instance at AWS.
Follow these steps to connect PostgreSQL using SSH Tunneling at AWS:
- Open PuTTY. Setup server session in Putty.
- Go to Connection > SSH > Tunnels
- Enter 8000 in the Source Port field.
- Enter 127.0.0.1:5432 in the Destination field.
- Click the “Add” button.
- Go back to Session, and save, then click “Open” to connect.
- This opens a terminal window. After connection leaves that alone.
- Open pgAdmin and add a connection.
- Enter localhost in the Host field and 8000 in the Port field.
- Specify a Name for the connection, and the username and password. Click OK.