欢迎登陆真网站,您的到来是我们的荣幸。 登陆 注册 忘记密码? ☆设为首页 △加入收藏
欢迎加入真幸福QQ群
电脑知识: 基础知识 网络技术 操作系统 办公软件 电脑维修 电脑安全 windows7 windows8 windows10 服务器教程 平板电脑 视频播放教程 网络应用 互联网 工具软件 浏览器教程 QQ技巧 输入法教程 影视制作 YY教程 wps教程 word教程 Excel教程 PowerPoint
云南西双版纳特产小花糯玉米真空包装


linux下时间同步的两种方法分享
怎样从应用商店升级Win8.1?
Win10自动维护怎么关闭?
win10快捷键有哪些?
Win7玩游戏无法连接到服务器如何解决?
win10主页怎么恢复初始状态恢复刚安装时的初始状态
word2013怎样对插入图片的样式进行设置
win10系统华硕vm510lj热键无法使用怎么办
怎样卸载Win8的内置应用?
edius怎么添加字幕
linux系统安全shell脚本第二版
【 来源:网络 】【 点击:1 】 【 发布时间:2017_03_03 08:59:59 】

   使用方法将其复制,保存为一个shell文件,比如security.sh.将其上传到linux服务器上,执行sh security.sh,就可以使用该脚本了!

  代码如下:

  #!/bin/sh

  # desc: setup linux system security

  # author:coralzd

  # powered by www.freebsdsystem.org

  # 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_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

本网站由川南居提供技术支持,fkzxf版权所有 浙ICP备12031891号
淳安分站 淳安分站