Linux主机安全配置规范

一、账号口令

1 配置口令最小长度

    在文件/etc/login.defs中设置 PASS_MIN_LEN,参考值:8

2 配置口令生存周期

    在文件/etc/login.defs中设置 PASS_MAX_DAYS,参考值:90

3 配置密码复杂度策略

    CentOS系统:修改/etc/pam.d/system-auth文件, 在ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 选3种,追加到password requisite pam_cracklib.so后面,添加到配置文件中。 
    例如:password requisite pam_cracklib.so ucredit=-1 lcredit=-1 dcredit=-1 
    注:ucredit:大写字母个数;lcredit:小写字母个数;dcredit:数字个数;ocredit:特殊字符个数

4 限定用户su到root

    编辑su文件(vi /etc/pam.d/su),在开头添加下面两行: 
    auth sufficient pam_rootok.so 
    auth required pam_wheel.so group=wheel

    这表明只有wheel组的成员可以使用su命令成为root用户。 

二、认证授权

1 设置文件与目录缺省权限

    在文件/etc/profile中设置umask 默认:022,可改为027

2 设置命令行界面超时退出

    编辑/etc/profile,增加 export TMOUT=300(单位:秒),重新登录时生效

3 禁止root用户远程ssh登录

    修改/etc/ssh/sshd_config文件,配置PermitRootLogin no 重启sshd服务生效

4 启用syslog日志审计

    编辑/etc/rsyslog.conf, 配置: authpriv.* /var/log/secure 并手动创建该文件,重启rsyslog生效

三、协议安全

1 禁止FTP匿名用户登录

    编辑/etc/vsftpd.conf(或/etc/vsftpd/vsftpd.conf)文件,设置:anonymous_enable=NO

2 禁止root登录VSFTP

    编辑/etc/ftpusers(或/etc/vsftpd/ftpusers)文件,添加root

3 SSH配置非22端口,禁用telnet协议

四、其他

1 删除.netrc 文件

    查找,find / -maxdepth 3 -name .netrc 2>/dev/null,重命名或者删除

2 删除hosts.equiv文件

    find / -maxdepth 3 -name hosts.equiv 2>/dev/null

3 删除.rhosts 文件

    find / -maxdepth 3 -name .rhosts 2>/dev/null

4 关闭不必要的服务和端口

    chkconfig --list

    chkconfig [--level levels] 服务名 off

5 删除系统banner信息,避免泄漏操作系统泄漏

    删除或重命名"/etc"目录下的 issue.net 和 issue 文件: 
    mv /etc/issue /etc/issue.bak 
    mv /etc/issue.net /etc/issue.net.bak

6 服务软件隐藏版本号等关键信息,并定期升级

猜你喜欢

转载自www.cnblogs.com/xstyle/p/9077780.html