forked from joseeden/KodeKloud_Engineer_Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TASK_17-Create_a_group.sh
318 lines (278 loc) · 9.38 KB
/
TASK_17-Create_a_group.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
-----------------------------------------------------------------------------------------------------------------
Start 2020-07-17 || 05:16 AM
Finished
-----------------------------------------------------------------------------------------------------------------
TASK 17 - Create a group
REQUIREMENT:
There are specific access levels for users defined by the xFusionCorp Industries system admin team. Rather than providing access levels to every individual user, the team has decided to create groups with required access levels and add users to that groups as needed. See the following requirements:
a. Create a group named nautilus_sftp_users in all App servers in Stratos Datacenter.
b. Add the user mohammed to nautilus_sftp_users in all App servers. (create the user if not present already)
-----------------------------------------------------------------------------------------------------------------
CONTENT:
I. REFERENCES
II. STEPS - SUMMARY
III. COMMANDS USED
IV. STEPS - BREAKDOWN
-----------------------------------------------------------------------------------------------------------------
I. REFERENCES
https://linuxhandbook.com/list-users-in-group-linux/
https://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/
https://linuxize.com/post/how-to-add-user-to-group-in-linux/
https://community.kodekloud.com/t/task-creating-a-group-and-adding-an-user-to-group-on-all-application-servers/1103
https://community.kodekloud.com/t/failed-create-group-and-add-user/1134/2
-----------------------------------------------------------------------------------------------------------------
II. STEPS - SUMMARY
1. Connect via SSH to each App Server.
2. Create the group
3. Add user to the group then verify.
-----------------------------------------------------------------------------------------------------------------
III. COMMANDS USED
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
sudo groupadd nautilus_developers
sudo useradd -G nautilus_developers jarod
sudo usermod -a -G nautilus_developers jarod
getent passwd | grep jarod
getent group nautilus_developers
getent group
-----------------------------------------------------------------------------------------------------------------
IV. STEPS - BREAKDOWN
# This was actually one of the fairly easy but I complicated it that's why it took me around an hour
# or more before I finally decided to hit finis.
# When I was creating the group and the use and then when I check th elist of groups, the username always appears
# in the grouplist.
# Thinking that somehow the command I'm usign is also creating a 2nd group and uses the username,
# I kept modifying the commands I used. I also looked in the net and KKC for the solution.
# When I ws already at many attempts, I decided to just follow the commands listed in one article
# in KKC and disregard if the username appears in the group list.
# After doing it for the 3 servers and hitting finish, it didn't showed an error. it actually worked.
# So lesson-learn: don't overthink things.
# I guess I was just consumed by the idea of not failing the lab that it held me back from actually finishing the lab
# faster.
# Also, I might need to recall/study more on the user and group creation.
# It's basic, I know, but yeah. we all need to get down the basics before succeeding at somethign difficult.
thor@jump_host /$ sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]: Permanently added '172.16.238.10' (ECDSA) to the list of known hosts.
[tony@stapp01 ~]$ getent grouproot:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ansible,tony
cdrom:x:11:mail:x:12:
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
ssh_keys:x:998:
sshd:x:74:
ansible:x:1000:
tony:x:1001:
[tony@stapp01 ~]$ sudo groupadd nautilus_developers
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for tony:
[tony@stapp01 ~]$ sudo useradd -G nautilus_developers jarod
[tony@stapp01 ~]$ sudo usermod -a -G nautilus_developers jarod
[tony@stapp01 ~]$ getent passwd | grep jarod
jarod:x:1002:1003::/home/jarod:/bin/bash
[tony@stapp01 ~]$
[tony@stapp01 ~]$ getent group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ansible,tony
cdrom:x:11:
mail:x:12:
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
ssh_keys:x:998:
sshd:x:74:
ansible:x:1000:
tony:x:1001:
nautilus_developers:x:1002:jarod
jarod:x:1003:
[tony@stapp01 ~]$ getent group nautilus_developers
nautilus_developers:x:1002:jarod
[tony@stapp01 ~]$
[tony@stapp01 ~]$ exit
logout
Connection to 172.16.238.10 closed.
thor@jump_host /$
thor@jump_host /$
thor@jump_host /$ sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
Warning: Permanently added '172.16.238.11' (ECDSA) to the list of known hosts.
[steve@stapp02 ~]$
[steve@stapp02 ~]$ sudo groupadd nautilus_developers
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for steve:
[steve@stapp02 ~]$
[steve@stapp02 ~]$ sudo useradd -G nautilus_developers jarod
[steve@stapp02 ~]$ sudo usermod -a -G nautilus_developers jarod
[steve@stapp02 ~]$ getent passwd | grep jarod
jarod:x:1002:1003::/home/jarod:/bin/bash
[steve@stapp02 ~]$ getent group nautilus_developers
nautilus_developers:x:1002:jarod
[steve@stapp02 ~]$
[steve@stapp02 ~]$ getent group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ansible,steve
cdrom:x:11:
mail:x:12:
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
ssh_keys:x:998:
sshd:x:74:
ansible:x:1000:
steve:x:1001:
nautilus_developers:x:1002:jarod
jarod:x:1003:
[steve@stapp02 ~]$ exit
logout
Connection to 172.16.238.11 closed.
thor@jump_host /$
thor@jump_host /$ sshpass -p '******' ssh -o StrictHostKeyChecking=no [email protected]
Warning: Permanently added '172.16.238.12' (ECDSA) to the list of known hosts.
[banner@stapp03 ~]$
[banner@stapp03 ~]$ sudo groupadd nautilus_developers
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for banner:
[banner@stapp03 ~]$
[banner@stapp03 ~]$ sudo useradd -G nautilus_developers jarod
[banner@stapp03 ~]$ sudo usermod -a -G nautilus_developers jarod
[banner@stapp03 ~]$ getent passwd | grep jarod
jarod:x:1002:1003::/home/jarod:/bin/bash
[banner@stapp03 ~]$ getent group nautilus_developers
nautilus_developers:x:1002:jarod
[banner@stapp03 ~]$ getent group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:ansible,banner
cdrom:x:11:
mail:x:12:
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
input:x:999:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
ssh_keys:x:998:
sshd:x:74:
ansible:x:1000:
banner:x:1001:
nautilus_developers:x:1002:jarod
jarod:x:1003:
[banner@stapp03 ~]$
[banner@stapp03 ~]$
[banner@stapp03 ~]$ exit
logout
Connection to 172.16.238.12 closed.
thor@jump_host /$ Connection to host01 closed by remote host.
Connection to host01 closed.
-----------------------------------------------------------------------------------------------------------------
############################################################################################################
####### ### ### ####### ####### ######### ####### ####### ### ###
#### #### ### ### #### #### #### #### ######### #### #### #### #### ### ###
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ### ### ### ### ###
####### ### ### ### ### ######## ####### ####### ### ###
####### ### ### ### ### ######## ####### ####### ### ###
### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ### ### ### ### ### ### ### ###
######### ######### #### #### #### #### ######### ######### ######### ### ###
####### ####### ####### ####### ######### ####### ####### ### ###
############################################################################################################