# Overview

Now that our Ubuntu instance is running on AWS EC2, we will now SSH into our instance and configure PostgreSQL (Version 12.4).

In this chapter, I will give instructions and rationale on how to do the following:

1. Install PostgreSQL
2. Create roles for PostgreSQL
3. Allow for remote connections

Be sure to SSH into your instance before following the instructions.

### References

*Guides*

(1) TecMint, *How to Install PostgreSQL and pgAdmin4 in Ubuntu 20.04*, <https://www.tecmint.com/install-postgresql-and-pgadmin-in-ubuntu/>

(2) DigitalOcean, *How To Install and Use PostgreSQL on Ubuntu 20.04*, <https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-20-04>

(3) Better Programming (Medium), *How to Provision a Cheap PostgreSQL Database in AWS EC2*, <https://medium.com/better-programming/how-to-provision-a-cheap-postgresql-database-in-aws-ec2-9984ff3ddaea>

(4) The Geek Stuff, *How to Allow Remote Connection to PostgreSQL Database using psql*, <https://www.thegeekstuff.com/2014/02/enable-remote-postgresql-connection/>

*Documentations*

(5) PostgreSQL 12 Documentation, *Chapter 20. Client Authentication*, <https://www.postgresql.org/docs/13/client-authentication.html>

(6) PostgreSQL 12 Documentation, *20.1. The pg\_hba.conf File*, <https://www.postgresql.org/docs/12/auth-pg-hba-conf.html>

(7) PostgreSQL 12 Documentation, *20.5. Password Authentication*, <https://www.postgresql.org/docs/12/auth-password.html>

(8) PostgreSQL 12 Documentation, *19.3 Connections and Authentications*, <https://www.postgresql.org/docs/12/runtime-config-connection.html>

*Forums*

(9) StackExchange, *Difference between sudo user and root user*, <https://unix.stackexchange.com/questions/291454/difference-between-sudo-user-and-root-user>

(10) StackOverflow, *How do I exit the vim editor?*, <https://stackoverflow.com/questions/11828270/how-do-i-exit-the-vim-editor>

(11) AskUbuntu, *How to install updates via command line?*, <https://askubuntu.com/questions/196768/how-to-install-updates-via-command-line>

(12) AskUbuntu, *Is there a command to list all users? Also to add, delete, modify users, in the terminal?*, <https://askubuntu.com/questions/410244/is-there-a-command-to-list-all-users-also-to-add-delete-modify-users-in-the>

(13) Unix StackExchange, *What is the difference between su username and su - username?*, <https://unix.stackexchange.com/questions/384700/what-is-the-difference-between-su-username-and-sudo-su-username>

(14) AskUbuntu, *'sudo su -' vs 'sudo -i' vs 'sudo /bin/bash' - when does it matter which is used, or does it matter at all?,* <https://askubuntu.com/questions/376199/sudo-su-vs-sudo-i-vs-sudo-bin-bash-when-does-it-matter-which-is-used>

(15) Stack Overflow, *How to configure PostgresSQL postgresql.conf listen\_addresses for multiple ip addresses* <https://stackoverflow.com/questions/9764126/how-to-configure-postgresql-postgresql-conf-listen-addresses-for-multiple-ip-add>

(16) AskUbuntu, *What does -y mean in apt get -y install command,*  <https://askubuntu.com/questions/672892/what-does-y-mean-in-apt-get-y-install-command>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aws-postgresql-docs.beliciarodriguez.com/ubuntu-configuring-instance/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
