Policy Level | Description |
DEFAULT | Default level. Allows TLS 1.2 and 1.3 protocols, as well as IKEv2 and SSH2 protocols. |
LEGACY | Compatibility policy. Additionally supports TLS 1.0 and 1.1 protocols on top of DEFAULT, and allows DSA, 3DES, and RC4 algorithms. |
FUTURE | Conservative security level. SHA-1 is not allowed in signature algorithms. TLS 1.2 and 1.3 protocols, as well as IKEv2 and SSH2 protocols, are allowed. |
# View the current encryption policyupdate-crypto-policies --show# Set the policy to FUTUREupdate-crypto-policies --set FUTURE
reboot
/etc/crypto-policies/back-ends/ directory.# wget example: customizing TLS versions and cipher suiteswget --secure-protocol=TLSv1_1 --ciphers="SECURE128" https://example.com# curl example: specifying a cipher listcurl https://example.com --ciphers '@SECLEVEL=0:DES-CBC3-SHA:RSA-DES-CBC3-SHA'
# 1. Create a subpolicy file.cd /etc/crypto-policies/policies/modules/touch MYCRYPTO-1.pmod
MYCRYPTO-1.pmod:min_rsa_size = 3072hash = SHA2-384 SHA2-512 SHA3-384 SHA3-512
# 2. Enable the subpolicy.update-crypto-policies --set DEFAULT:MYCRYPTO-1# 3. Restart to take effectreboot# 4. Verificationcat /etc/crypto-policies/state/CURRENT.pol | grep rsa_size
# 1. Create a policy file. You can copy a system predefined policy as a base.cp /usr/share/crypto-policies/policies/DEFAULT.pol /etc/crypto-policies/policies/MYPOLICY.pol# 2. Edit the policy file content.vim /etc/crypto-policies/policies/MYPOLICY.pol# 3. Enable the custom policy.update-crypto-policies --set MYPOLICY# 4. Restart to take effectreboot# 5. Verificationupdate-crypto-policies --show
Purpose | Path |
Trust anchor | /usr/share/pki/ca-trust-source/anchors/ or /etc/pki/ca-trust/source/anchors/ |
Untrusted certificates | /usr/share/pki/ca-trust-source/blacklist/ or /etc/pki/ca-trust/source/blacklist/ |
Certificates in extended format | /usr/share/pki/ca-trust-source/ or /etc/pki/ca-trust/source/ |
/etc/pki/ca-trust/ take precedence over those in /usr/share/pki/ca-trust-source/.# Install ca-certificates (usually preinstalled)dnf install ca-certificates# Copy the certificate to the trust anchor directory.cp ~/certificate.pem /usr/share/pki/ca-trust-source/anchors/# Update the system certificate store.update-ca-trust
# List all trust anchors.trust list# Add a trust anchor.trust anchor path/to/certificate.crt# Delete a trust anchor.trust anchor --remove path/to/certificate.crt# View subcommand help.trust list --help
Tool | Description |
SCAP Workbench | Graphical interface tool that performs configuration and vulnerability scans on a single system and generates security reports. |
OpenSCAP(oscap) | Command line tool that performs configuration and vulnerability scans on the local system and supports compliance remediation. |
SCAP Security Guide(SSG) | Security policy collection that provides XCCDF configuration files and OVAL detection scripts for Linux systems. |
Script Check Engine(SCE) | Optional extension that supports writing custom check logic with scripts such as Bash and Python. |
# Install AIDE.dnf install aide# Initialize the database.aide --init# Enable the database (remove .new from the filename).mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
/etc/aide.conf, where you can define the directories and files to monitor.# Check whether files have been tampered with.aide --check# Update the database after system changes.aide --updatemv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
aes-xts-plain64, with a default key size of 512 bits.# 1. Format as a LUKS partition.cryptsetup luksFormat /dev/vdb1# 2. Open the encrypted partition.cryptsetup open /dev/vdb1 vdb1_encrypted# 3. Create a file system.mkfs -t ext4 /dev/mapper/vdb1_encrypted# 4. Mount the file system.mount /dev/mapper/vdb1_encrypted /mnt/encrypted
# Unmount the partition.umount /dev/vdb1# Install cryptsetup.dnf install cryptsetup# Enable encryption (the LUKS header is stored at the beginning of the device)cryptsetup reencrypt --encrypt --init-only --reduce-device-size 32M /dev/vdb1 vdb1_encrypted
cryptsetup reencrypt --encrypt --init-only --header /path/to/header /dev/vdb1 vdb1_encrypted
/dev/mapper/./etc/audit/auditd.conf. Common parameters:Parameter | Description |
log_file | Audit log path. Default: /var/log/audit/audit.log |
max_log_file | Maximum log file size |
max_log_file_action | Action when the log reaches its limit. Recommended value: keep_logs. |
space_left | Disk free space threshold |
space_left_action | Action when space is insufficient. Recommended value: email. |
disk_full_action | Action when the disk is full. Set to halt or single. |
flush | Log flush mode. Recommended value: incremental_async. |
# Start the service and enable it to start on boot.systemctl start auditdsystemctl enable auditd# Check the status.systemctl status auditd# Reload the configuration.service auditd reload
# Monitor file access (record write operations to /etc/passwd)auditctl -w /etc/passwd -p wa -k passwd_changes# Monitor directories (record write operations to the /etc/selinux/ directory)auditctl -w /etc/selinux/ -p wa -k selinux_changes# System call rules (record time-related system calls)auditctl -a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time_change# Record user file deletion operations.auditctl -a always,exit -S unlink -S unlinkat -S rename -S renameat -F auid>=1000 -F auid!=4294967295 -k delete# Record executable file execution.auditctl -a always,exit -F exe=/bin/id -F arch=b64 -S execve -k execution_bin_id
.rules file in the /etc/audit/rules.d/ directory, and then load them:# Load rulesaugenrules --load# View loaded rulesauditctl -l
# Search for specific event typesausearch -m AVC,USER_AVC -ts recent# Search for login failure recordsausearch -m USER_LOGIN -ts '7/02/2022' '18:00:00' -sv no# Generate login reportsaureport --login -i# Generate reports for all eventsaureport
usbguard generate-policy only allow USB devices that are already connected when the command is run. After USBGuard is enabled on a physical server, newly connected devices such as keyboards and mice are denied by default, which may result in the loss of local access. You are advised to check the rule set and keep an out-of-band management channel (such as BMC/IPMI) available before enabling the service. If you are locked out, you can run systemctl stop usbguard through the out-of-band channel to recover.# Install USBGuarddnf install usbguard# Generate an initial rule set based on currently connected devices.usbguard generate-policy > /etc/usbguard/rules.conf# Start the service and enable it to start on boot.systemctl enable --now usbguard# Check the service status.systemctl status usbguard
# List identified USB devices.usbguard list-devices# Temporarily authorize devices to interact with the system.usbguard allow-device <device_id># Temporarily deny devices.usbguard reject-device <device_id># Permanently authorize devices (write rules)usbguard allow-device <device_id> -p# Permanently deny devices.usbguard block-device <device_id> -p# View current rules.usbguard list-rules
# Generate a policy (without hashes)usbguard generate-policy --no-hashes > ./rules.conf# Edit rules, for example, to allow only high-capacity storage devices.vim ./rules.conf# Add: allow with-interface equals { 08:*:* }# Install a policy.install -m 0600 -o root -g root rules.conf /etc/usbguard/rules.conf# Restart to take effectsystemctl restart usbguard
/etc/usbguard/usbguard-daemon.conf and change AuditBackend to LinuxAudit:AuditBackend=LinuxAudit
systemctl restart usbguard# Verificationausearch -ts recent -m USER_DEVICE
Mode | Description |
enforcing | Enforce security policies. Access that violates rules is denied and logged. |
permissive | Permissive mode. Violations are only logged, not denied. |
disabled | Disable SELinux. |
# View the current mode.getenforcesestatus# Temporarily switch modessetenforce 0 # Switch to permissive modesetenforce 1 # Switch to enforcing mode
/etc/selinux/config, set SELINUX=enforcing|permissive|disabled, and then restart.semanage login -m -s user_u -r s0 __default__ modifies the default user mapping and affects all subsequently logging-in unmapped users (except explicitly mapped users such as root). Verify the impact in a test environment before using it in production. To restore, run semanage login -m -s unconfined_u -r s0 __default__.# View SELinux user mappingssemanage login -l# Map the default user to user_u (restrict regular users)semanage login -m -s user_u -r s0 __default__# Create a restricted administrator useradduser -G wheel -Z sysadm_u <username>
audit2allow based on existing denial logs may be overly broad and grant more permissions than necessary. After generation, review the rules in mypolicy.te to confirm that the authorization scope is appropriate before installing it with semodule -i.# 1. Search AVC denial logsausearch -m AVC,USER_AVC,SELINUX_ERR -ts recent# 2. If no logs are found, they may be suppressed by dontaudit rulessemodule -DB # Temporarily disable dontaudit# 3. Use sealert to view detailed analysissealert -l "*"# 4. Automatically generate a policy with audit2allowaudit2allow -M mypolicy < /var/log/audit/audit.logsemodule -i mypolicy.pp# 5. Restore the dontaudit rules.semodule -B
フィードバック