CentOS 7 系统安全加固方案

一、 操作系统

1 密码长度与有效期

[root@i-1y3we23j ~]# cat /etc/login.defs |grep PASS_ |grep -v '#'
PASS_MAX_DAYS    99999
PASS_MIN_DAYS    0
PASS_MIN_LEN    5
PASS_WARN_AGE    7

2 密码复杂度

1.备份配置文件:
# cp -a /etc/pam.d/system-auth /etc/pam.d/system-auth.default
2.编辑配置文件
# vi /etc/pam.d/system-auth
将password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
 注释并在其下面新增1行 password requisite pam_cracklib.so try_first_pass minlen=8 difok=5 dcredit=-1 lcredit=-1 ocredit=-1 retry=1 type= 3.保存配置文件

3 设置会话超时(5分钟)

1.备份配置文件:
# cp -a /etc/profile /etc/profile.default
2.编辑配置文件:
vi /etc/profile
在文件的末尾添加参数 
export TMOUT=300

4 设置history命令时间戳

1.备份配置文件:
2.编辑配置文件:
vi /etc/profile
在文件的末尾添加参数
export HISTTIMEFORMAT="%F %T `whoami` "

5 设置登陆失败锁定(终端登录)

1.备份配置文件
2.编辑配置文件:
# vi /etc/pam.d/system-auth
在# User changes will be destroyed the next time authconfig is run.行的下面,添加
auth       required     pam_tally2.so deny=5 unlock_time=1800 even_deny_root root_unlock_time=1800

6 禁止root通过ssh远程登录

1.备份配置文件
# cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.default
2.编辑配置文件
vi /etc/ssh/sshd_config
将配置参数#PermitRootLogin yes改成PermitRootLogin no
3.创建普通用户
useradd admin 
passwd admin 
4.重启sshd服务
systemctl restart sshd.service

7 SSH 配置参数增强

1.备份配置文件
2.编辑配置文件
#vi /etc/ssh/sshd_config

(1)禁止空密码登录
将#PermitEmp
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值