# 禁止通过 ctrl-alt-del 快捷键重启服务器
# mask ctrl-alt-del.target unit (this in fact creates symlink to /dev/null)
systemctl mask ctrl-alt-del.target
# 验证
ls -l /etc/systemd/system/ctrl-alt-del.target
lrwxrwxrwx 1 root root 9 Mar 23 14:51 /etc/systemd/system/ctrl-alt-del.target -> /dev/null
# SSH 服务配置
# vim sshd_config
# 输入密码错误超过 3 次,则记录到日志里
MaxAuthTries 3
# 允许用户使用密码登录,默认 yes
PasswordAuthentication yes
# Specifies whether rhosts or /etc/hosts.equiv authentication together with successful RSA host authentication is allowed.
# The default is “no”. This option applies to protocol version 1 only.
RhostsRSAAuthentication no
# 不允许以空密码登录,默认 no
PermitEmptyPasswords no
# 严格模式
# Specifies whether sshd should check file modes and ownership of the user’s files and home directory before accepting login.
# This is normally desirable because novices sometimes accidentally leave their directory or files world-writable. The default is “yes”.
StrictModes yes
# 日志记录级别
# Gives the verbosity level that is used when logging messages from sshd. The possible values are: QUIET, FATAL, ERROR, INFO,
# VERBOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3. The default is INFO.
LogLevel INFO
# Specifies whether sshd should ignore the user’s ~/.ssh/known_hosts during RhostsRSAAuthentication or HostbasedAuthentication. The default is “no”.
IgnoreUserKnownHosts yes
# 加密方式 + 号的方式在 RHEL7+、Kylin V7+ 版本支持
Ciphers +3des-cbc
# Specifies the available MAC (message authentication code) algorithms.
MACs +hmac-sha1,hmac-md5
# 禁止 usb 功能
# vim /etc/modprobe.d/usb_storage.conf
install usb-storage /bin/true
# 重载配置
rmmod usb-storage
# auditd 配置
# vim /etc/audit/auditd.conf
# 最大保留的日志文件数
# This keyword specifies the number of log files to keep if rotate is given as the max_log_file_action.
num_logs 4
# 单文件 50MB 后触发轮转
# This keyword specifies the maximum file size in megabytes.
max_log_file = 50
max_log_file_action = ROTATE
# 只特定用户从特定客户端登录
# 首先在 ssh 启用 pam_access.so 验证
# vim /etc/pam.d/sshd
account required pam_access.so
# grants the user bakroot access to all hosts except 10.0.0.2 and 10.0.0.3.
# Here's a breakdown of the line:
# - indicates that this is a deny rule. If the line started with a +, it would be a permit rule.
# bakroot is the user that the rule applies to.
# ALL is a keyword that means "all hosts".
# EXCEPT is a keyword that means "except the following hosts".
# 10.0.0.2 and 10.0.0.3 are the IP addresses of the hosts that the user bakroot should not have access to.
# So, in summary, this rule denies access to the user bakroot for all hosts except 10.0.0.2 and 10.0.0.3.
# vim /etc/security/access.conf
- : bakroot : ALL EXCEPT 10.0.0.2 10.0.0.3