#!/bin/bash
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #
# Filename: install_zabbix_agent.sh #
# Revision: 0.0.3 #
# Date: 2018-07-26 #
# Author: Huajian Qiu <mu@zhimajihua.com> #
# Description: Install Zabbix Agent for CentOS X. #
# License: GPLv2 #
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #
#修改密码策略
sed -i.bak 's@^\(PASS\)@#\1@' /etc/login.defs
cat >> /etc/login.defs <<EOF
PASS_MAX_DAYS 90
PASS_MIN_DAYS 1
PASS_MIN_LEN 8
PASS_WARN_AGE 7
EOF
#启用鉴别登录失败处理功能
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
cat >> /etc/ssh/sshd_config <<EOF
LoginGraceTime 30
PermitRootLogin no
MaxAuthTries 2
EOF
service sshd restart
#密钥认证 sudoer selinux 资源限制 跳过
#超时锁定
cp /etc/profile /etc/profile.bak
cat >> /etc/profile <<EOF
export TMOUT=300
readonly TMOUT
EOF
#审计
service auditd restart
chkconfig auditd on
#添加用户
useradd testuser
echo "weihu@devops" | passwd --stdin testuser