Linux Security Flashcards

1
Q

How do you check if AppArmor is up and running?

A

sudo aa-status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you setup a port/protocol rule on ufw

A

sudo ufw allow PORT/PROTOCOL comment “STRING”

You don’t need the comment but would help if an unusual port etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you add more than one port to the ufw rule

A

eg. “… allow 21,22/tcp …”. For itemised

or
“…. allow 30000:40000/udp …” for a range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Prioritise a ufw rule to the top of the table

A

sudo ufw prepend RULE …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to insert a ufw rule into a specific point on the table

A

First:
sudo ufw status numbered

Then:
sudo ufw insert LINE NO RULE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Create a ufw rule for ssh with a more restricted scope of inbound sources I.e local machines only

A

sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Remove a ufw rule

A

sudo ufw status numbered
sudo ufw remove LINE NO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s the syntax for adding an entry to the bottom of the sudoers file?

A

username ALL=(ALL) All
Where from=(who as). What commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Where is the sudoers file?

A

/etc/sudoers

Edit with Visudo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Where is the SE Linux configuration

A

/etc/selinux/config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Default policy setting of SELinux?

A

Targeted: Only enforces network daemon policy rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Non default SEL settings

A

minimum - only specified process
mls - US military & gov
strict - all daemons, not recommended

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to change SEL state

A

sudo getenforce permissive/enforcing

To disable you have to change the config file!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What utility do you use to view and set SEL context for user accounts?

A

semanage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does chcon do and What is the syntax?

A

Change default SEL context;
chcon -u USER -r ROLE -t TYPE /FILE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where does SEL log its security events?

A

/var/log/audit/audit.log.
Can use audit2allow to generate policy to allow a denied event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

AppArmor is usually installed by default in Ubuntu but what packages might you need to get?

A

apparmor-utils
apparmor-profiles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Where are AppArmor profiles stored?

A

/etc/apparmor.d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is noteworthy about AA profile names?

A

That usually reference the application path but swap the / for .
eg usr.bin.mysqld

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you view a list of active network ports without an AA profile defined?

A

sudo aa-unconfined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you turn off (but not disable) an AA profile?

A

aa-complain Profile_PATH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you turn an AA profile off and on?

A

sudo aa-disable PATH
sudo aa-enforce PATH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What tools are required to setup joining AD?

A

sssd-ad, sssd-tools, realmd, adcli

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do you test if you can join the AD realm (domain)?

A

sudo realm -v discover DOMAIN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Once everything is setup, how do you join an AD domain (realm)?
sudo realm join -U USER@DOMAIN domain.name
26
What tools required to connect a current sys to OpenLDAP
libnss-ldapd, libpam-ldapd, ldap-utils
27
Where do you modify an individual users ssh config?
~/.ssh/config
28
Where do you modify every user’s ssh config?
/etc/ssh/ssh_config
29
Where do you modify an ssh server (incoming) config?
/etc/ssh/sshd_config
30
What is the full command to generate an SSH ID key pair?
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519
31
How would you send your pubkey to the remote SSH server?
ssh-copy-id USER@HOST For a dry run then use -n
32
How to check if a program is compatible to use PAM
ldd /bin/PATH | grep libpam.so
33
Where are would a PAM compatible program have its config file?
/etc/pam.d
34
Three common PAM modules for enforcing strong passwords?
pam_unix.so pam_pwhistory.so pam_pwquality.so (pam_cracklib.so)
35
Two PAM modules to protect against brute force
pam_tally.so (Deb) pam_faillock.so (Rhel)
36
PAM module to incorporate into an LDAP env?
pam_ldap.so
37
How do you check firewalld is running?
firewall-cmd —state Or systemctl status firewalld
38
Commands to modify firewalld zones
firewall-cmd —get-zones —get-default-zone —set-default-zone=ZONE —get-active-zones —permanent —new-zone=NEWZONE
39
Change an interface to a diff firewalld zone - 2 steps to do this.
Modify the adapter config in /etc/sysconfig/network-scripts Then systemctl restart firewalld
40
How to add/remove a service(common proto) rule to firewalld
firewall-cmd zone=ZONE —add/remove-service=SERVICE (SERVICE from —get-services)
41
How do you save firewalld rules beyond current session
Add —permanent Or reload the firewall
42
How to add a nonstandard service/port role to firewalld
—zone=ZONE —permanent —add-port=PORT/PROTO (tcp/udp)
43
Keep going old chap
You got this
44
Give an example of a standard ACCEPT for iptables (http for this example)
iptables -A INPUT -p tcp —dport 80 -j ACCEPT
45
Give an example of an iptables rule to block ssh from a specific source
iptables -A INPUT -s 6.6.6.6 -p tcp —dport 22 REJECT/DROP
46
How to make an iptables adjustment persist
iptables-save or on some distros there’s no -
47
What are the three different chains in iptables?
INPUT FORWARD OUTPUT
48
How might you monitor in a state in iptables?
(…) -m state —state RELATED, ESTABLISHED (…)
49
What file to edit password requirements?
/etc/login.defs
50
The /etc/login.defs file can modify settings for password length and age, but how might you go about fixing a complexity requirement.
Add the pwquality.so module into the PAM rules and edit appropriately.
51
How would you edit settings for the PAM pwquality.so module?
RHEL - /etc/pam.d/system-auth and password-auth DEB - /etc/pam.d/common-password and common-auth Then add appropriate directives to the end of the line: “password requisite pam_pwqualty.so”
52
What’s an easy trick to restrict service accounts (especially root) from making system changes
Edit their /etc/passwd to run the /usr/bin/nologin as their default shell. That we they can operate but not run scripts etc
53
How might you stop someone from walking up to the console and using root login?
Create a file /etc/securetty on the system. If nothing in it that means no consoles are permitted access with root.
54
How do you block root access over ssh?
Modify the /etc/ssh/sshd_config file and edit the appropriate commented line.
55
How to disable/change ctrl alt del?
systemctl mask ctrl-alt-del.target On sysV you need to modify the appropriate line in /etc/inittab
56
How would you secure ‘at’ and ‘cron’
They have at.allow and cron.deny files in /etc
57
How would you pass on messages to users?
/etc/login.warn /etc/motd
58
How to block USB storage devices?
Modify /etc/modbrope.d/blacklist.conf with the lines: blacklist uas blacklist usb:storage Save then reboot!
59
How to improve and customise security logging?
Use the auditd package: Edit /etc/audit/audit.rules and use auditctl command
60
Top 4 services you should consider disabling?
FTP Telnet Finger Mail services
61
What are two really easy network security layers you might want to consider implementing:
TCP wrappers .allow and .deny Also hosts.allow and .deny
62
How is the SELinux security context format laid out
User:Type:Role:Level
63
An easy method of checking and enabling/disabling SE Linux policies?
getsebool -a setsebool (-P) POLICY on/off
64
How do you read the SEL /var/log/audit/audit.log ?
use audit2allow
65
What are the 4 PAM service types?
Account Auth Password Session
66
What are the 6 PAM control-flags
Include Optional Requisite Required Substack Sufficient
67
pam_tally2.so and pam_faillock.so shared options are?
deny=n silent unlock_time=n
68
Unlock with pam_tally2
sudo pam_tally2 -r -u USER
69
Where are UFW profiles stored
/etc/default/ufw/applications.d
70
Why is /bin/nologin used?
It prevents a (sys account) user from logging in from any terminal
71
See the firewalld zone you’re in and rules attached to them
firewall-cmd —list-all Also use —zone=NAME for a different zone to what you’re on
72
Where to make actual AppArmor profile changes
/etc/apparmor.d/local