缘来路过 发表于 2018-5-22 12:30:13

linux 安全加固

---1.使用Shell历史命令记录功能
#/etc/bashrc

HISTFILESIZE=4000   
HISTSIZE=4000   
HISTTIMEFORMAT='%F %T'
export HISTTIMEFORMAT

source /etc/bashrc


---2.删减系统登录欢迎信息

---2.1删除记录了操作系统的名称和版本号
# vi /etc/ssh/sshd_config#添加如下记录

Banner /etc/issue.net

---2.2 删除全部内容或更新成自己想要添加的内容

# vi /etc/motd

---3.system timeout 5 minite auto logout
echo "TMOUT=300" >>/etc/profile
source /etc/profile

----4.加固

# chmod危险文件
chmod 700 /bin/ping
chmod 700 /usr/bin/finger
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 700 /usr/bin/locate
chmod 700 /usr/bin/whereis
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/pico
chmod 700 /bin/vi
chmod 700 /usr/bin/which
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/make
chmod 700 /bin/rpm
# history安全
chattr +a /root/.bash_history
chattr +i /root/.bash_history

# chattr /etc/passwd /etc/shadow
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow

# add syncookie enable /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf

sysctl -p

#修改配置文件
vi /etc/login.defs
PASS_MAX_DAYS 90 #新建用户的密码最长使用天数
PASS_MIN_DAYS 0 #新建用户的密码最短使用天数
PASS_WARN_AGE 7 #新建用户的密码到期提前提醒天数
PASS_MIN_LEN 9 #最小密码长度9

---5.限制哪些账户能切换到root
1) #vi /etc/pam.d/su
auth required /lib/security/pam_wheel.so group=dba

#usermod -Gdba test将test用户加入到dba组  
页: [1]
查看完整版本: linux 安全加固