Skip to main content

PostgreSQL

Version: 15.2 | OS: Ubuntu 22.04

Overview

PostgreSQL is a powerful, open-source object-relational database system known for reliability, robust feature support, and high performance.

Included Software

  • PostgreSQL - 15.2

Firewall & Access

PortServicePurpose
22SSH (rate limited)Secure server access
5432PostgreSQLDatabase access

Initial Deployment

During the deployment process:

  • PostgreSQL is installed and configured
  • You will be logged out with the message:

Please wait until the installation is completed....
Connection to $IPADDRESS closed.

Wait at least 2 minutes before logging back in.

Accessing the Instance

  1. Login to your instance:
ssh ubuntu@$IPADDRESS
  1. Switch to root:
sudo su -

Accessing PostgreSQL

  • The PostgreSQL superuser password is stored at:
/root/.postgresql_passwords
  • Login as postgres user:
sudo -u postgres psql

Enable Remote Access

  1. Edit the postgresql.conf file:
nano /etc/postgresql/15/main/postgresql.conf

Uncomment and update the following line:

listen_addresses = '*'
  1. Edit the pg_hba.conf file:
nano /etc/postgresql/15/main/pg_hba.conf

Update this line to allow connections from any IP:

host    all             all             0.0.0.0/0            scram-sha-256
  1. Restart PostgreSQL:
systemctl restart postgresql
  1. Allow port 5432 through the firewall.

Connect Remotely

psql -h $IPADDRESS -U postgres

Replace $IPADDRESS with your PostgreSQL server's public IP.