Linux的系统安全设置Shell脚本
建议根据自己的实际需要来修改此脚本,不要盲目使用!
#!/bin/sh
# desc: setup linux system security
# author:coralzd
# powered by
# version 0.1.2 written by 2011.05.03
#account setup
passwd -l xfs
passwd -l news
passwd -l nscd
passwd -l dbus
passwd -l vcsa
passwd -l games
passwd -l nobody
passwd -l avahi
passwd -l haldaemon
passwd -l gopher
passwd -l ftp
passwd -l mailnull
passwd -l pcap
passwd -l mail
passwd -l shutdown
passwd -l halt
passwd -l uucp
passwd -l operator
passwd -l sync
passwd -l adm
passwd -l lp
# chattr /etc/passwd /etc/shadow
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow
# add continue input failure 3 ,passwd unlock time 5 minite
sed -i 's#auth required pam_#auth required pam_nauth required pam_ onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_ onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
# system timeout 5 minite auto logout
echo "TMOUT=300" 》/etc/profile
# will system save history command list to 10
sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile
# enable /etc/profile go!
source /etc/profile
# add syncookie enable /etc/nf
echo "p_syncookies=1" 》 /etc/nf
sysctl -p # exec nf enable
# optimizer sshd_config
sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
# limit chmod important commands
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 security
chattr +a /root/.bash_history
chattr +i /root/.bash_history
# write important command md5
cat > list 《 "EOF" &&
/bin/ping
/bin/finger
/usr/bin/who
/usr/bin/w
/usr/bin/locate
/usr/bin/whereis
/sbin/ifconfig
/bin/pico
/bin/vi
/usr/bin/vim
/usr/bin/which
/usr/bin/gcc
/usr/bin/make
/bin/rpm
EOF
for i in `cat list`
do
if [ ! -x $i ];then
echo "$i not found,no md5sum!"
else
md5sum $i 》 /var/log/`hostname`.log
fi
done
rm -f list
- 瑞士巴索金属切削液大丰干燥设备气模高尔夫鞋物品包装Frc
- 徐乐江以互联网驱动钢铁业转型空调塔城车圈塑料助剂螺尖丝锥Frc
- OTT猛烈冲击广电运营商急需去广电化防伪印刷紧定衬套仪器仪表胶合板六角螺帽Frc
- 河南省啤酒市场亟待净化震动电机机筒螺杆收银台耐腐蚀泵蝶阀Frc
- 艾默生网络能源携手中国银行安徽省分行推进铜陵玻璃印刷烘干设备密封法兰藏饰手链Frc
- 一项技术革新让竹浆湿浆造纸企业获得新生连接法兰液压冲床伺服阀服装加盟航空接头Frc
- 国际碳纤维产业分析及全球产能状况塑料轴承别克配件二手仪表绿植硬化胶Frc
- 广州石化PS现定价销售肇庆音乐IC船用电缆竹胶板皮辊磨床Frc
- 水性油墨用助剂的选择丹江口切碎机操作系统绢云母搪塑玩具Frc
- 2016年7月7日塑料原料ABS价格行情天水作文家教乳胶床垫探伤仪对焊法兰Frc