#!/bin/sh
# script name:nping
# use this script to confirm the hosts are alive or not
HOST01="xxx.xxx.xxx.xxx"
HOST02="xxx.xxx.xxx.xxx"
HOST03="xxx.xxx.xxx.xxx"
HOST04="xxx.xxx.xxx.xxx"
HOST05="xxx.xxx.xxx.xxx"
HOST06="xxx.xxx.xxx.xxx"
HOST07="xxx.xxx.xxx.xxx"
HOST08="xxx.xxx.xxx.xxx"
HOST09="xxx.xxx.xxx.xxx"
HOST10="xxx.xxx.xxx.xxx"
for LOOP in $HOST01 $HOST02 $HOST03 $HOST04 $HOST05 $HOST06 $HOST07 $HOST08 $HOST09 $HOST10
do
if !/sbin/ping -c 2 $LOOP >/dev/null 2>&1;then
echo "Warning:The host $LOOP seems down" >> error.log
fi
done
if [ -f error.log ];then
cat error.log |mail -s "Warning:Host Down" yourname@yourmail.com
rm –rf error.log
fi
#!/bin/sh
# script name:nscan
# use this script to check the services status on local servers
HOST01="xxx.xxx.xxx.xxx"
HOST02="xxx.xxx.xxx.xxx"
HOST03="xxx.xxx.xxx.xxx"
HOST04="xxx.xxx.xxx.xxx"
HOST05="xxx.xxx.xxx.xxx"
HOST06="xxx.xxx.xxx.xxx"
HOST07="xxx.xxx.xxx.xxx"
SQL_PORT="2433/tcp"
MSRDP_PORT="3389/tcp"
PCANYWH_PORT="5631/tcp"
for LOOP in $HOST01 $HOST02 $HOST03 $HOST04 $HOST05 $HOST06 $HOST07
do
nmap -sT $LOOP >nmap.tmp 2>&1
for PORT in $SQL_PORT $MSRDP_PORT $PCANYWH_PORT
do
if ! grep $PORT nmap.tmp >/dev/null 2>&1;then
echo “Warning:The port $PORT is seem to down on $LOOP” >>$LOOP.error
fi
done
if [ ! -f $LOOP.error ];then
echo "The services running on $LOOP are nomal!"
else
cat $LOOP.error >>nscan.err 2>&1
rm -rf $LOOP.error
fi
rm -rf nmap.tmp
done
if [ -f nscan.err ];then
cat nscan.err |mail –s “Host Services Down” yourname@yourmail.com
rm –rf nscan.err
fi
4.4 用户管理
用户管理通常是指系统的用户帐户管理,不管是UNIX系统还是Windows系统,帐户安全是系统安全的关键。系统中应保持固定数量的用户帐户,作为系统管理员,应清楚每一个帐户的使用者和用途。用户新申请帐户应该有个流程,规范的管理总比不规范好。
在Unix系统上,大多数系统帐户平时是没什么用的,包括:bin daemon adm lp mail news uucp operator games gopher rpc等,如果你不把它们删除,那么也不要让它们拥有真正的shell,检查/etc/passwd文件,看看这些帐户的最后一个域(shell)是否被置/sbin/nologin或/bin/false。经常检查帐户的权限,普通帐户不应该在root组(gid=0),更不应拥有root权限(uid=0)。可以写一个脚本来替你检查,如下所示:
#!/bin/sh
# script name:checkuser
# check if there is any user who have real shell or have root id/gid
if [ "$USER_SHELL" != "/sbin/nologin" ];then
echo -e "\n$USER has one real shellUSER_SHELL"
fi
if [ $USER_UID -eq 0 ];then
echo "$USER has the root uid(uid 0)"
fi
if [ $USER_GID -eq 0 ];then
echo "$USER has the root gid(gid 0)"
fi