Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  shell  >  正文 Linux系统安全设置Shell脚本

Linux系统安全设置Shell脚本

发布时间:2014-09-29   编辑:www.jquerycn.cn
Linux系统安全设置Shell脚本,脚本仅供参考,建议根据自己的实际需要来修改此脚本,不要盲目使用!

Linux系统安全设置Shell脚本,脚本仅供参考,建议根据自己的实际需要来修改此脚本,不要盲目使用!
 

复制代码 代码如下:
 #!/bin/sh 
 # desc: setup linux system security 
 # author:coralzd 
 #account setup 
 
 passwd -l xfsx
 passwd -l newsx 
 passwd -l nscdx 
 passwd -l dbusx 
 passwd -l vcsax 
 passwd -l gamesx 
 passwd -l nobodyx 
 passwd -l avahi 
 passwd -l haldaemonx 
 passwd -l gopher 
 passwd -l ftp 
 passwd -l mailnull 
 passwd -l pcapx 
 passwd -l mail 
 passwd -l shutdownx 
 passwd -l haltx 
 passwd -l uucpx 
 passwd -l operatorx 
 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_env.so#auth required pam_env.sonauth required pam_tally.so onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_tally.so 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/sysctl.conf 
 echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf 
 
 sysctl -p # exec sysctl.conf 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

您可能感兴趣的文章:
inux shell初级入门教程
Linux mkkickstart命令
python shell是什么
Linux系统安全设置Shell脚本
Python3 解释器
python脚本如何测试手机
solaris10默认shell修改与设置
Shell 教程
source命令执行shell文件与shell script文件名直接运行的区别
linux系统安全shell第二版(超强大)

[关闭]