Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| hardening [2019/02/07 17:09] – [Filesystem encryption] admin | hardening [2024/11/30 10:22] (current) – [Managing Accounts] dani | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Hardening ====== | + | ====== Hardening |
| ===== Updates ===== | ===== Updates ===== | ||
| Line 52: | Line 52: | ||
| <code bash> | <code bash> | ||
| - | dd if=/ | + | dd if=/ |
| + | chmod 0600 < | ||
| + | cryptsetup luksAddKey / | ||
| </ | </ | ||
| * Add the encrypted partition into / | * Add the encrypted partition into / | ||
| - | <file - / | + | <code bash> |
| < | < | ||
| </ | </ | ||
| Line 63: | Line 65: | ||
| * The /etc/fstab should contain a line like this: | * The /etc/fstab should contain a line like this: | ||
| - | <file - /etc/fstab> | + | <code bash> |
| / | / | ||
| </ | </ | ||
| Line 120: | Line 122: | ||
| <code bash> | <code bash> | ||
| - | setfacl -m u:dani:rwx / | + | setfacl -m u:dani:rwx / |
| + | getfacl test/ | ||
| + | # file: opt/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user:: | ||
| + | user: | ||
| + | group:: | ||
| + | mask:: | ||
| + | other:: | ||
| + | </ | ||
| + | |||
| + | * Grants read/ | ||
| + | <code bash> | ||
| + | setfacl -m g::rx / | ||
| + | getfacl / | ||
| + | # file: opt/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user:: | ||
| + | user: | ||
| + | group:: | ||
| + | mask:: | ||
| + | other::r-x | ||
| </ | </ | ||
| - | * Grants read/ | ||
| * Grants read/ | * Grants read/ | ||
| <code bash> | <code bash> | ||
| - | setfacl -m g:wheel:rx / | + | setfacl -m g:wheel:rx / |
| + | getfacl / | ||
| + | # file: opt/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user:: | ||
| + | user: | ||
| + | group:: | ||
| + | group: | ||
| + | mask:: | ||
| + | other::r-x | ||
| </ | </ | ||
| Line 187: | Line 221: | ||
| Usually the password and account ageing is configured in ''/ | Usually the password and account ageing is configured in ''/ | ||
| - | {{:images/Hardening/users.png| User management}} | + | {{:images:users.png? |
| === PAM Modules === | === PAM Modules === | ||
| Line 342: | Line 376: | ||
| <code xml> | <code xml> | ||
| - | < | + | < |
| - | <HTML> | + | < |
| - | < | + | < |
| - | </ | + | < |
| - | false | + | < |
| - | < | + | < |
| - | </ | + | < |
| - | </ | + | <locale name=" |
| - | < | + | |
| + | | ||
| + | </ | ||
| + | </ | ||
| - | < | + | < |
| - | <HTML> | + | < |
| - | < | + | < |
| - | </ | + | < |
| - | </ | + | < |
| - | < | + | < |
| + | < | ||
| + | <locale name=" | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | </ | ||
| </ | </ | ||
| Line 387: | Line 430: | ||
| <code shell> | <code shell> | ||
| - | cp / | + | cp / |
| + | # delete unwanted entries in config! | ||
| + | aide --init | ||
| + | aide --check | ||
| </ | </ | ||
| Line 398: | Line 444: | ||
| * Prepare server for '' | * Prepare server for '' | ||
| - | < | + | < |
| - | chkconfig NetworkManager off; service NetworkManager stop ... vim / | + | chkconfig NetworkManager off; service NetworkManager stop |
| + | ... | ||
| + | vim / | ||
| + | DEVICE=" | ||
| + | BOOTPROTO=" | ||
| + | HWADDR=" | ||
| + | IPV6INIT=" | ||
| + | MTU=" | ||
| + | NM_CONTROLLED=" | ||
| + | ONBOOT=" | ||
| + | TYPE=" | ||
| + | UUID=" | ||
| + | IPADDR=192.168.0.101 | ||
| + | NETMASK=255.255.255.0 | ||
| + | GATEWAY=192.168.0.254 | ||
| + | DNS1=192.168.0.254 | ||
| - | vim /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.0.X+100 serverX.example.com serverX | + | vim /etc/hosts |
| + | 127.0.0.1 localhost.localdomain localhost | ||
| + | ::1 localhost6.localdomain6 localhost6 | ||
| + | 192.168.0.X+100 serverX.example.com serverX | ||
| chkconfig network on; service network restart | chkconfig network on; service network restart | ||
| Line 424: | Line 488: | ||
| <code bash> | <code bash> | ||
| - | kinit admin Password for admin@EXAMPLE.COM: | + | kinit admin |
| + | Password for admin@EXAMPLE.COM: | ||
| ipa user-find admin | ipa user-find admin | ||
| Line 446: | Line 511: | ||
| <code bash> | <code bash> | ||
| - | getent passwd admin | + | getent passwd admin |
| + | getent group admins | ||
| + | kinit admin | ||
| </ | </ | ||
| Line 452: | Line 519: | ||
| <code bash> | <code bash> | ||
| - | ipa user-add gpyle --first=Gomer --last=Pyle --password | + | ipa user-add gpyle --first=Gomer --last=Pyle --password |
| + | ipa user-add cboyle --first=Charles --last=Boyle --password | ||
| + | ... | ||
| </ | </ | ||
| Line 470: | Line 539: | ||
| <code bash> | <code bash> | ||
| - | ipa sudocmd-add --desc "For displaying logs" / | + | ipa sudocmd-add --desc "For displaying logs" / |
| + | ipa sudocmdgroup-add --desc "List logs" loglist | ||
| + | ipa sudocmdgroup-add-member --sudocmds "/ | ||
| + | ipa sudorule-add --hostcat " | ||
| + | ipa sudorule-add-option loglist-attr | ||
| + | ipa sudorule-add-user --groups marines loglist-attr | ||
| + | ipa sudorule-add-allow-command --sudocmdgroups loglist loglist-attr | ||
| </ | </ | ||
| Line 485: | Line 560: | ||
| </ | </ | ||
| - | ## Rsyslog | + | ===== Rsyslog |
| * Make sure the NTP time is working fine on all invoked systems! | * Make sure the NTP time is working fine on all invoked systems! | ||
| * Create and change into directory ('' | * Create and change into directory ('' | ||
| - | < | + | < |
| - | mkdir ca cd ca | + | mkdir ca |
| + | cd ca | ||
| </ | </ | ||
| Line 525: | Line 601: | ||
| Common name: serverX.example.com | Common name: serverX.example.com | ||
| - | Is this a TLS web client certificate? | + | Is this a TLS web client certificate? |
| + | Is this also a TLS web server certificate? | ||
| </ | </ | ||
| Line 532: | Line 609: | ||
| <code bash> | <code bash> | ||
| - | certtool --generate-certificate --load-request serverX-request.pem --outfile serverX-cert.pem --load-ca-certificate ca.pem --load-ca-privkey ca-key.pem | + | certtool --generate-certificate --load-request serverX-request.pem --outfile serverX-cert.pem |
| + | --load-ca-certificate ca.pem --load-ca-privkey ca-key.pem | ||
| The certificate will expire in (days): 1000 | The certificate will expire in (days): 1000 | ||
| - | Is this a TLS web client certificate? | + | Is this a TLS web client certificate? |
| + | Is this also a TLS web server certificate? | ||
| + | Enter a dnsName of the subject of the certificate: | ||
| </ | </ | ||
| Line 544: | Line 624: | ||
| <code bash> | <code bash> | ||
| - | # make gtls driver the default $DefaultNetstreamDriver gtls | + | # make gtls driver the default |
| + | $DefaultNetstreamDriver gtls | ||
| - | # certificate files $DefaultNetstreamDriverCAFile / | + | # certificate files |
| + | $DefaultNetstreamDriverCAFile / | ||
| + | $DefaultNetstreamDriverCertFile / | ||
| + | $DefaultNetstreamDriverKeyFile / | ||
| $ModLoad imtcp # load TCP listener | $ModLoad imtcp # load TCP listener | ||
| - | $InputTCPServerStreamDriverMode 1 # run driver in TLS-only mode $InputTCPServerStreamDriverAuthMode anon # client is NOT authenticated $InputTCPServerRun 6514 # listen on port 6514 | + | $InputTCPServerStreamDriverMode 1 # run driver in TLS-only mode |
| + | $InputTCPServerStreamDriverAuthMode anon # client is NOT authenticated | ||
| + | $InputTCPServerRun 6514 # listen on port 6514 | ||
| </ | </ | ||
| Line 556: | Line 642: | ||
| <code bash> | <code bash> | ||
| - | # certificate files - just CA for a client $DefaultNetstreamDriverCAFile / | + | # certificate files - just CA for a client |
| + | $DefaultNetstreamDriverCAFile / | ||
| - | # set up the action $DefaultNetstreamDriver gtls # use gtls netstream driver $ActionSendStreamDriverMode 1 # require TLS for the connection $ActionSendStreamDriverAuthMode anon # server is NOT authenticated | + | # set up the action |
| + | $DefaultNetstreamDriver gtls # use gtls netstream driver | ||
| + | $ActionSendStreamDriverMode 1 # require TLS for the connection | ||
| + | $ActionSendStreamDriverAuthMode anon # server is NOT authenticated | ||
| + | *.* @@(o)serverX.example.com: | ||
| </ | </ | ||
| * Create ''/ | * Create ''/ | ||
| - | * Add following lines into ''/ | + | * Add following lines into ''/ |
| <code bash> | <code bash> | ||
| - | # process | + | curl file:/// |
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | # process | ||
| + | : | ||
| + | # then discard them | ||
| + | : | ||
| </ | </ | ||
| Line 576: | Line 674: | ||
| The trace command is probably useful (Example for date): | The trace command is probably useful (Example for date): | ||
| - | < | + | < |
| autrace /bin/date | autrace /bin/date | ||
| Waiting to execute: /bin/date | Waiting to execute: /bin/date | ||
| Line 585: | Line 683: | ||
| ausearch --raw -p 26572 | aureport --file -i | ausearch --raw -p 26572 | aureport --file -i | ||
| </ | </ | ||
| + | |||
| ===== Iptables ===== | ===== Iptables ===== | ||
| Using '' | Using '' | ||
| - | < | + | < |
| Chain INPUT (policy ACCEPT 0 packets, 0 bytes) | Chain INPUT (policy ACCEPT 0 packets, 0 bytes) | ||
| num pkts bytes target | num pkts bytes target | ||
| Line 612: | Line 711: | ||
| A very basic example script to initialize '' | A very basic example script to initialize '' | ||
| - | < | + | < |
| iptables -F | iptables -F | ||
| iptables -A INPUT -i lo -j ACCEPT | iptables -A INPUT -i lo -j ACCEPT | ||
| Line 624: | Line 723: | ||
| To delete a rule: | To delete a rule: | ||
| - | < | + | < |
| iptables -D INPUT 11 | iptables -D INPUT 11 | ||
| </ | </ | ||
| Line 630: | Line 729: | ||
| To add a rule (insert): | To add a rule (insert): | ||
| - | < | + | < |
| iptables -I INPUT 11 | iptables -I INPUT 11 | ||
| </ | </ | ||