1
00:00:00,470 --> 00:00:02,191
- [Instructor] Hi and
welcome back to the course.

2
00:00:02,191 --> 00:00:05,802
In this video, we're going
to be creating another user

3
00:00:05,802 --> 00:00:09,653
so that we don't have to
log in as the root user,

4
00:00:09,653 --> 00:00:11,986
just for increased security.

5
00:00:13,187 --> 00:00:14,950
When we log in as the root user,

6
00:00:14,950 --> 00:00:17,936
I've mentioned the root user
is a very important user

7
00:00:17,936 --> 00:00:20,315
in a Unix and it has
access to do anything,

8
00:00:20,315 --> 00:00:22,838
so it potentially can mess up your server,

9
00:00:22,838 --> 00:00:26,428
making sure that you have
to create another one.

10
00:00:26,428 --> 00:00:28,443
So the root user has a lot of power,

11
00:00:28,443 --> 00:00:30,713
and sometimes that is very useful.

12
00:00:30,713 --> 00:00:32,993
For example, when installing applications

13
00:00:32,993 --> 00:00:36,919
in your server, you want
to do it as the root user

14
00:00:36,919 --> 00:00:39,408
so it has access to modify
all of the different

15
00:00:39,408 --> 00:00:41,942
files and folders in your server.

16
00:00:41,942 --> 00:00:45,857
But normally, you don't
want to be the root user

17
00:00:45,857 --> 00:00:48,484
just because the root user
has so many permissions

18
00:00:48,484 --> 00:00:51,824
that if you instal something, for example,

19
00:00:51,824 --> 00:00:54,638
and everything you do is
done by the root user,

20
00:00:54,638 --> 00:00:57,760
other users, such as the Postgres user,

21
00:00:57,760 --> 00:01:01,467
may not have access to the
files and folders you create

22
00:01:01,467 --> 00:01:03,134
using the root user.

23
00:01:03,976 --> 00:01:05,540
So what we're gonna do,
is we're gonna create

24
00:01:05,540 --> 00:01:09,623
a new user by following
the command adduser Jose.

25
00:01:11,592 --> 00:01:15,216
The name here is the name of
the user that we're creating,

26
00:01:15,216 --> 00:01:16,339
and I'm calling it Jose.

27
00:01:16,339 --> 00:01:18,813
You can call it your name
or whatever you want,

28
00:01:18,813 --> 00:01:20,588
but just know that this
is going to come up

29
00:01:20,588 --> 00:01:24,561
over and over again, so
whenever I type Jose,

30
00:01:24,561 --> 00:01:27,012
you're going to have
to type your username.

31
00:01:27,012 --> 00:01:30,607
But apart from that,
that's everything you need.

32
00:01:30,607 --> 00:01:32,908
And what this does, is
that creates a new user

33
00:01:32,908 --> 00:01:36,747
called Jose, and it creates a new group

34
00:01:36,747 --> 00:01:38,710
called Jose, as well.

35
00:01:38,710 --> 00:01:41,547
A group is a collection of users

36
00:01:41,547 --> 00:01:44,238
and you can set group permissions.

37
00:01:44,238 --> 00:01:48,170
For example, you may tell
Unix, your Ubuntu server,

38
00:01:48,170 --> 00:01:51,489
that all users in the
group Jose have access

39
00:01:51,489 --> 00:01:54,170
to a specific folder, for example.

40
00:01:54,170 --> 00:01:56,570
And then, even if an individual
users doesn't have access

41
00:01:56,570 --> 00:01:58,709
to that folder, because
they are in the group

42
00:01:58,709 --> 00:02:00,023
they will have access to it.

43
00:02:00,023 --> 00:02:03,263
It's just a way of setting
permissions in Unix.

44
00:02:03,263 --> 00:02:06,691
Next, we're going to set
the password for this user,

45
00:02:06,691 --> 00:02:09,197
and make sure that that's
different from the root password,

46
00:02:09,197 --> 00:02:11,364
just for security as well.

47
00:02:13,876 --> 00:02:17,367
Okay, then you can put in your full name,

48
00:02:17,367 --> 00:02:18,480
which I will do,

49
00:02:18,480 --> 00:02:19,313
and then there's a few things

50
00:02:19,313 --> 00:02:20,947
that I'm just gonna leave blank.

51
00:02:20,947 --> 00:02:22,196
There.

52
00:02:22,196 --> 00:02:24,098
Finally, we get this prompt,

53
00:02:24,098 --> 00:02:25,603
is the information correct,

54
00:02:25,603 --> 00:02:28,053
and because the Y is a capital letter,

55
00:02:28,053 --> 00:02:31,648
that is the default value
that we're gonna select

56
00:02:31,648 --> 00:02:32,755
if we leave it blank,

57
00:02:32,755 --> 00:02:36,495
so just pressing enter
makes sure that we say

58
00:02:36,495 --> 00:02:38,805
that the information is correct.

59
00:02:38,805 --> 00:02:40,451
Okay?

60
00:02:40,451 --> 00:02:42,406
The next thing we have to do is make sure

61
00:02:42,406 --> 00:02:46,277
that the Jose user can
temporarily gain access

62
00:02:46,277 --> 00:02:48,994
to being root so that we can do things

63
00:02:48,994 --> 00:02:51,502
like instal programmes
and things like that.

64
00:02:51,502 --> 00:02:55,669
Way we're gonna do that is by
running the visudo command.

65
00:02:56,853 --> 00:03:01,094
Okay, this brings you to a
reasonably scary-looking window,

66
00:03:01,094 --> 00:03:03,205
but this is just a file,

67
00:03:03,205 --> 00:03:05,555
and what we're gonna do is
we're gonna modify this file

68
00:03:05,555 --> 00:03:09,722
so that the Jose user has
access to being root sometimes.

69
00:03:12,284 --> 00:03:14,249
So we want to find, by
pressing the arrows,

70
00:03:14,249 --> 00:03:17,847
this line here that says
user privilege specification,

71
00:03:17,847 --> 00:03:22,690
and under root ALL=(ALL:ALL)
ALL, we're gonna type

72
00:03:22,690 --> 00:03:26,857
Jose ALL=(ALL:ALL) ALL,
so essentially copying it

73
00:03:29,730 --> 00:03:33,112
but putting in your user
name at the beginning.

74
00:03:33,112 --> 00:03:35,575
Notice that the spacing between
these things doesn't matter.

75
00:03:35,575 --> 00:03:38,383
I just left it there for
readability purposes,

76
00:03:38,383 --> 00:03:40,216
but it doesn't matter.

77
00:03:41,109 --> 00:03:44,604
Once that's done, we're
going to save the file

78
00:03:44,604 --> 00:03:46,482
to the disc and we're gonna do that

79
00:03:46,482 --> 00:03:48,629
by running this command here,

80
00:03:48,629 --> 00:03:53,278
which is CTRL+O, and then
we're gonna press enter

81
00:03:53,278 --> 00:03:56,215
to save it on top of the existing file,

82
00:03:56,215 --> 00:04:00,311
and finally we're gonna
press CTRL+X to exit.

83
00:04:00,311 --> 00:04:02,394
And that's, that's saved.

84
00:04:03,321 --> 00:04:04,777
The next thing we have
to do is to make sure

85
00:04:04,777 --> 00:04:07,146
that we can login to the server directly

86
00:04:07,146 --> 00:04:11,626
as the Jose user, as
opposed to the root user.

87
00:04:11,626 --> 00:04:15,793
So what we're gonna do is
press vi /etc/ssh/sshd_config.

88
00:04:21,997 --> 00:04:26,164
So vi /etc/ssh/sshd_config.

89
00:04:29,929 --> 00:04:33,165
And this brings you to another
nice-looking text file,

90
00:04:33,165 --> 00:04:35,956
and what we want to find
here is one specific line.

91
00:04:35,956 --> 00:04:38,895
So I'm gonna go down
pressing the down arrow,

92
00:04:38,895 --> 00:04:42,441
until you find this line
that says PermitRootLogin,

93
00:04:42,441 --> 00:04:44,077
and it says yes.

94
00:04:44,077 --> 00:04:47,302
That means that we can login to the server

95
00:04:47,302 --> 00:04:50,475
as the root user, and
this is not very safe.

96
00:04:50,475 --> 00:04:54,535
We should not be allowing
people to login as the root user

97
00:04:54,535 --> 00:04:57,768
because if the root password gets cracked,

98
00:04:57,768 --> 00:05:01,073
then our server is in a bit of trouble.

99
00:05:01,073 --> 00:05:04,653
So we're going to press
the I key in your keyboard

100
00:05:04,653 --> 00:05:06,607
and that goes into insert mode,

101
00:05:06,607 --> 00:05:11,108
and then we're going to delete
the yes and put no instead.

102
00:05:11,108 --> 00:05:15,275
Then we're gonna press the
escape key to leave insert mode.

103
00:05:16,493 --> 00:05:18,704
Then we're gonna go down to
the very bottom of the file,

104
00:05:18,704 --> 00:05:20,704
which can be a bit long,

105
00:05:21,571 --> 00:05:24,354
and we are going to, right down here,

106
00:05:24,354 --> 00:05:27,140
press the I key again
to go into insert mode,

107
00:05:27,140 --> 00:05:29,813
go to the very end of
the line and press enter,

108
00:05:29,813 --> 00:05:33,230
and we're going to write AllowUsers Jose,

109
00:05:34,289 --> 00:05:36,643
and then press escape again.

110
00:05:36,643 --> 00:05:38,757
What this does is it tells SSH,

111
00:05:38,757 --> 00:05:40,327
which is our connection protocol,

112
00:05:40,327 --> 00:05:44,610
to allow the Jose user to
connect with this server.

113
00:05:44,610 --> 00:05:47,172
So we've denied the root
user from connecting

114
00:05:47,172 --> 00:05:51,149
and now we're gonna allow
the Jose user to connect.

115
00:05:51,149 --> 00:05:51,982
Okay?

116
00:05:51,982 --> 00:05:53,277
So you have to make
sure that your password

117
00:05:53,277 --> 00:05:55,583
for the Jose user is quite strong

118
00:05:55,583 --> 00:05:57,820
because, remember, the
Jose user has access

119
00:05:57,820 --> 00:05:59,849
to being root as well.

120
00:05:59,849 --> 00:06:03,102
So if your Jose user
password is very weak,

121
00:06:03,102 --> 00:06:06,019
that poses a security threat there.

122
00:06:07,785 --> 00:06:08,733
Okay?

123
00:06:08,733 --> 00:06:12,364
So then, once you've pressed
escape to leave insert mode,

124
00:06:12,364 --> 00:06:16,049
we want to press :wq
and what that means is

125
00:06:16,049 --> 00:06:19,113
write and quit, so it's
gonna save the file,

126
00:06:19,113 --> 00:06:22,521
write it to the disc, and quit.

127
00:06:22,521 --> 00:06:24,389
And finally, at the
very end, we want to say

128
00:06:24,389 --> 00:06:26,056
service sshd reload,

129
00:06:28,110 --> 00:06:29,768
and what that does is
that reloads the service

130
00:06:29,768 --> 00:06:33,351
and allows us to use
the new configuration.

131
00:06:34,364 --> 00:06:35,197
Okay?

132
00:06:36,177 --> 00:06:37,877
Now we're gonna press exit,

133
00:06:37,877 --> 00:06:41,517
which is going to
disconnect from the server,

134
00:06:41,517 --> 00:06:45,184
and we can do ssh Jose@
and the server here.

135
00:06:47,409 --> 00:06:48,576
Oh, apologies.

136
00:06:50,679 --> 00:06:51,851
And then we're gonna press enter,

137
00:06:51,851 --> 00:06:54,055
and now it asks us for
the Jose user password,

138
00:06:54,055 --> 00:06:56,065
which we're gonna put in,

139
00:06:56,065 --> 00:07:00,121
and now we're logged in as the Jose user.

140
00:07:00,121 --> 00:07:02,685
Now, this user has access to being root,

141
00:07:02,685 --> 00:07:06,874
so the way we would be
root, or login as root now

142
00:07:06,874 --> 00:07:11,019
would be sudo su and
that is going to ask us

143
00:07:11,019 --> 00:07:12,117
for our password again,

144
00:07:12,117 --> 00:07:13,526
which we're going to put in,

145
00:07:13,526 --> 00:07:16,928
and now we are logged in as the root user.

146
00:07:16,928 --> 00:07:19,233
We can press exit, and that brings us back

147
00:07:19,233 --> 00:07:21,169
to being the Jose user,

148
00:07:21,169 --> 00:07:22,938
and then we can press exit again

149
00:07:22,938 --> 00:07:25,662
and that brings us back to our computer.

150
00:07:25,662 --> 00:07:28,358
So now we've logged out of the server.

151
00:07:28,358 --> 00:07:29,574
Okay?

152
00:07:29,574 --> 00:07:30,702
So that's everything for this video.

153
00:07:30,702 --> 00:07:33,326
We've created a new user and
now we're going to make sure

154
00:07:33,326 --> 00:07:35,262
that PostgreSQL is linked to that user

155
00:07:35,262 --> 00:07:39,254
so we can use PostgreSQL
while we are the Jose user,

156
00:07:39,254 --> 00:07:42,364
or your user if you've
created a different name.

157
00:07:42,364 --> 00:07:43,541
So that's everything for this video,

158
00:07:43,541 --> 00:07:45,123
and I'll see you in the next one.

