服务器 频道

服务器托管一般性设置<4>

  【IT168 服务器学院】6.  操作系统安全设置
  
  6.1 FREEBSD安全设置
  
  删除登陆时出现的系统信息提示
  
  # > /etc/motd
  # touch /etc/COPYRIGHT
  # ee /etc/rc.conf
  update_motd="NO"
  
  关闭一些不安全的服务
  
  # vi /etc/rc.conf
  
  sendmail_enable="NONE"
  nfs_server_enable="NO"
  nfs_client_enable="NO"
  portmap_enable="NO"
  syslogd_enable="YES"
  syslogd_flags="-ss"
  icmp_drop_redirect="YES"
  clear_tmp_enable="YES"
  inetd_enable="NO"
  
  禁止一般用户查看系统日志
  
  # chmod g-w,o-r /var/log/*
  # chmod 600 /etc/syslog.conf
  # chmod 600 /etc/newsyslog.conf
  
  为了防止cracker利用rootkit工具通过后门进入系统,对/bin,/sbin进行安全保护
  
  # chflags schg /bin/*
  # chflags schg /sbin/*
  
  把系统的核心的运行层次设置为最安全的层次
  
  # sysctl -w kern.securelevel=2
  
  打开磁盘配额
  
  # vi /etc/rc.conf
  enable_quotas="YES"
  check_quotas="YES"
  
  禁止一般用户使用crontab,建立/etc/cron/allow文件把需要使用的用户放进去
  
  # echo root > /var/cron/allow
  # chmod 600 /var/cron/allow

  6.2 OPENBSD安全设置
  
  屏蔽登陆时的系统信息
  
  # > /etc/motd
  # vi /etc/rc           //这里注释掉了MOTD相关的行
  ============================== rc ===========================
  # patch /etc/motd
  #if [ ! -f /etc/motd ]; then
  #       install -c -o root -g wheel -m 664 /dev/null /etc/motd
  #fi
  #T=`mktemp /tmp/_motd.XXXXXXXXXX`
  #if [ $? -eq 0 ]; then
  #       sysctl -n kern.version | sed 1q > $T
  #       echo "" >> $T
  #       sed ''1,/^$/d'' < /etc/motd >> $T
  #       cmp -s $T /etc/motd || cp $T /etc/motd
  #       rm -f $T
  #fi
  ============================== rc ===========================
  
  停用SENDMAIL
  
  # vi /etc/rc.conf
  sendmail_flags=NO
  
  修改计划任务
  # vi /etc/daily
  找到下面代码
  ===========+===========+===========+============
  sh /etc/security 2>;&1 >; $OUT
  if [ -s $OUT ]; then
  mail -s "$host daily insecurity output" root < $OUT
  fi
  ===========+===========+===========+============
  修改如下
  ===========+===========+===========+============
  sh /etc/security 2>;&1 >; $OUT.TMP
  if [ -s $OUT.TMP ]; then
  echo "$host daily insecurity output" >; $OUT
  cat $OUT.TMP >;>; $OUT
  rm $OUT.TMP
  /usr/libexec/mail.local root >; $OUT
  fi
  ===========+===========+===========+============
  
  # crontab –e
  将下面三行:
  ===========+===========+===========+============
  30 1 * * * /bin/sh /etc/daily 2>;&1 | tee /var/log/daily.out | mail - s "`/bin/hostname` daily output" root
  30 3 * * 6 /bin/sh /etc/weekly 2>;&1 | tee /var/log/weekly.out | mail -s "`/bin/hostname` weekly output" root
  30 5 1 * * /bin/sh /etc/monthly 2>;&1 | tee /var/log/monthly.out | mail -s "`/bin/hostname` monthly output" root
  ===========+===========+===========+============
  修改如下:
  ===========+===========+===========+============
  30 1 * * * /bin/sh /etc/daily 2>;&1 | tee /var/log/daily.out | /usr/libexec/mail.local root
  30 3 * * 6 /bin/sh /etc/weekly 2>;&1 | tee /var/log/weekly.out | /usr/libexec/mail.local root
  30 5 1 * * /bin/sh /etc/monthly 2>;&1 | tee /var/log/monthly.out | /usr/libexec/mail.local root
  ===========+===========+===========+============
  
  禁用由inetd启动的程序
  
  # vi /etc/sysctl.conf
  inetd=NO
  
  禁止一般用户查看系统日志
  
  # chmod g-w,o-r /var/log/*
  
  为了防止cracker利用rootkit工具通过后门进入系统。对/bin,/sbin进行安全保护
  
  # chflags schg /bin/*
  # chflags schg /sbin/*
  
  把系统的核心的运行层次设置为最安全的层次
  
  # sysctl -w kern.securelevel=2
0
相关文章