Skip to content

Commit 58e5b5c

Browse files
author
Benjamin
committed
Added commands file with instructions for setting up new user with PostgreSQL
1 parent e72d14b commit 58e5b5c

File tree

2 files changed

+39
-2
lines changed
  • section9/lectures
    • 137_creating_a_unix_user_in_ubuntu_16
    • 138_setting_up_our_new_user_with_postgreSQL_permissions

2 files changed

+39
-2
lines changed

section9/lectures/137_creating_a_unix_user_in_ubuntu_16/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To create a new user, run the following command and enter the user details as pr
66
adduser jose
77
```
88

9-
# Add the new user to sudo users
9+
### Add the new user to sudo users
1010

1111
Running the visudo command will open a file (normally located at /etc/sudoers).
1212
```bash
@@ -21,7 +21,7 @@ jose ALL=(ALL:ALL) ALL
2121

2222
Save the file with CNTR+O and press enter to save it. Then CNTR+X to exit the file.
2323

24-
# To enable logging in to the server as the newly created user, enable password login to the server by running
24+
### To enable logging in to the server as the newly created user, enable password login to the server by running
2525

2626
```bash
2727
vi /etc/ssh/sshd_config
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Set up New User with PostgreSQL Permissions
2+
This section assumes you created a new unix user in Ubuntu 16.04 (instructions in the previous lecture) and you are logged into the server as the new user.
3+
4+
To become the postgres user, run
5+
6+
```bash
7+
sudo su
8+
sudo -i -u postgres
9+
```
10+
11+
To create a postgres user, run the following command. Note, the user must have the same name as the unix user logged into the server ("jose" in our case).
12+
13+
```bash
14+
createuser jose -P
15+
```
16+
17+
You will prompted twice to set the password for the new postgres user.
18+
19+
To create a database, run
20+
21+
```bash
22+
createdb jose
23+
```
24+
25+
To enforce password login to PostgreSQL with user jose, run the following commands. Note 9.5 is the PostgreSQL version installed in your server. Later this version may change so make sure to change your accordingly.
26+
27+
```bash
28+
vi /etc/postgresql/9.5/main/pg_hba.conf
29+
```
30+
31+
Scroll down to the bottom and change "peer" to "md5" in the following line under '# "local" is for unix domain socket connections only comment'. This is how the line should look after changing.
32+
33+
```bash
34+
local all all md5
35+
```
36+
37+
Finally, write and quit.

0 commit comments

Comments
 (0)