1、禁用telnet协议
systemctl status telnet
systemctl stop telnet
systemctl disable telnet
2、存在空口令账号: awk -F ":" '($2==""){print $1}' /etc/shadow
3、修改snmp默认团体字
/etc/snmp/snmpd.conf
1、修改团体名(snmpd的访问密码,默认为public,修改自己的)
com2sec notConfigUser default public
重启snmp服务
systemctl restart snmpd
禁止匿名用户登录FTP
vim /etc/vsftpd/vsftpd.conf
local_enable=Yes #启用本地用户
anonymous_enable=NO #关闭匿名用户访问
write_enable=YES #开放服务器的写权限(若要上传,必须开启)
local_umask=077
禁止root用户登录FTP
userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd/user_list
systemctl restart vsftpd.service
设置密码复杂度策略
debian
vim /etc/pam.d/common-password
redhat
vim /etc/pam.d/system-auth
password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 enforce_for_root
###
retry=3 定义登录/修改密码失败时,可以重试的次数;
minlen=8 密码最小长度为8个字符。
lcredit=-1 密码应包含的小写字母的至少一个
ucredit=-1 密码应包含的大写字母至少一个
dcredit=-1 将密码包含的数字至少为一个
ocredit=-1 设置其他符号的最小数量,例如@,#、! $%等,至少要有一个
enforce_for_root 确保即使是root用户设置密码,也应强制执行复杂性策略
检查是否设置口令生存周期
执行:cat /etc/login.defs,检查是否配置了以下参数。
PASS_MAX_DAYS 配置项决定密码最长使用期限;
PASS_MIN_DAYS 配置项决定密码最短使用期限;
PASS_WARN_AGE设置口令过期前警告天数;
设置命令行界面超时退出
debian
echo 'export TMOUT=1800' >> /etc/profile
redhat
echo 'export TMOUT=1800' >> /etc/bashrc
source /etc/bashrc
禁止root用户远程登录
系统默认目录:/etc/ssh/sshd_config
升级后的目录:/usr/openssh/openssh-9.8p1/etc/sshd_config
PermitRootLogin no
系统默认服务:systemctl status sshd.service
升级后的服务:systemctl status sshd9.service
使用PAM认证模块禁止wheel组之外的用户su为root
groupadd wheel
usermod -G wheel xxxxxx
编辑su文件(vim /etc/pam.d/su),在开头添加下面两行:
auth sufficient pam_rootok.so 和
auth required pam_wheel.so use_uid