Linux shell脚本编程详解及应用实例
#!/bin/bash#
#我判定可信任的ip地址,有两种情况:
# 1.当前正在登录的ip地址
# 2.成功登录过的ip地址
#allowip=`w -i| egrep -o"\" | uniq`
allowip=`last -i | grep-v"0.0.0.0"|egrep-o"\"| uniq`
for i in `echo $allowip|xargs -n1`;do
if [[ -z `grep $i /etc/hosts.allow` ]];then
echo "sshd: $i">>/etc/hosts.allow
fi
sleep 0.5
sync
done
count_all=`lastb -i -n 5000|egrep -v "\"|egrep -o "\
页:
[1]