-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSOME MUST COMMANDS
61 lines (52 loc) · 2.67 KB
/
SOME MUST COMMANDS
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
| You have to create a new user here. |
| $ sudo adduser username | <- creating new user (yes (no))
| $ sudo chage -l username | <- Verify password expire info for new user
| $ sudo adduser username sudo |
| $ sudo adduser username user42 | <- assign new user to sudo and user42 groups
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Q: How your script works?
A: ... README.md
##################################
# Part two: What to check? #
##################################
|***************************************|
| 1) lsblk 1 <- Check partitions
| 2) sudo aa-status 2 <- AppArmor status
| 3) getent group sudo 3 <- sudo group users
| 4) getent group user42 4 <- user42 group users
| 5) sudo service ssh status 5 <- ssh status, yep
| 6) sudo ufw status 6 <- ufw status
| 7) ssh username@ipadress -p 4242 7 <- connect to VM from your host (physical) machine via SSH
| 8) nano /etc/sudoers.d/<filename> 8 <- yes, sudo config file. You can $ ls /etc/sudoers.d first
| 9) nano /etc/login.defs 9 <- password expire policy
| 10) nano /etc/pam.d/common-password 10 <- password policy
| 11) sudo crontab -l 11 <- cron schedule
|***************************************|
I think this one need an addition to make it more easy to pass evaluation. So, here we are on our checklist and his commands.
How to change hostname?
[$sudo nano /etc/hostname]
Where is sudo logs in /var/log/sudo?
[$cd /var/log/sudo/00/00 && ls]
You will see a lot of directories with names like 01 2B 9S 4D etc. They contain the logs we need.
[$ sudo apt update]
[$ ls]
Now you see that we have a new directory here.
[$ cd <nameofnewdirectory> && ls]
[$ cat log] <- Input log
[$ cat ttyout] <- Output log
How to add and remove port 8080 in UFW?
[$ sudo ufw allow 8080] <- allow
[$ sudo ufw status] <- check
[$ sudo ufw deny 8080] <- deny (yes yes)
How to run script every 30 seconds?
[$ sudo crontab -e]
Remove or commit previous cron "schedule" and add next lines in crontab file
|*************************************************|
| */1 * * * * /path/to/monitoring.sh |
| */1 * * * * sleep 30s && /path/to/monitoring.sh |
|*************************************************|
To stop script running on boot you just need to remove or commit
|********************************|
| @reboot /path/to/monitoring.sh |
|********************************|