# PostgreSQL installation and configuration I- Installation sudo apt install postgresql II - Configuration ### Enable remote access Edit the PostgreSQL configuration file to allow remote connections: sudo nano /etc/postgresql/*/main/postgresql.conf # Replace * with your PostgreSQL version Find the line that starts with `listen_addresses` and change it to: plaintext listen_addresses = '*' III - Configure client authentication Set a password for the `postgres` user: sudo -u postgres psql template1 Then, in the PostgreSQL prompt, run: sql ALTER USER postgres WITH ENCRYPTED PASSWORD 'your_password'; VI - Edit the `pg_hba.conf` file Edit the `pg_hba.conf` file to allow remote connections: sudo nano /etc/postgresql/*/main/pg_hba.conf # Replace * with your PostgreSQL version Add the following line at the end of the file to allow all IP addresses to connect: hostssl template1 postgres 192.168.1.1/24 scram-sha-256 # Replace template1 with your database name, postgres with your username, and 192.168.1.1/24 with your network range # Or if you want to allow all the databases and users hostssl all all 192.168.1.1/24 scram-sha-256 V - Restart PostgreSQL to apply the changes: sudo systemctl restart postgresql VI - Connecting to PostgreSQL VII - Install the PostgreSQL client sudo apt install postgresql-client VIII - Connect to PostgreSQL You can connect to PostgreSQL using the `psql` command: psql -h your_server_ip -U postgres --password --dbname template1 # Replace `your_server_ip` with the IP address of your PostgreSQL server