机器需要重新启动吗?

sh/bash/dash/ksh/zsh等Shell脚本
回复
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

机器需要重新启动吗?

#1

帖子 whaha » 2018-01-25 20:56

下面的代码可以将那些反复尝试登录ssh的ip地址写入/etc/hosts.deny

代码: 全选

cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/black.txt 
DEFINE="5" 
for i in `cat  /root/black.txt` 
do 
  IP=`echo $i |awk -F= '{print $1}'` 
  NUM=`echo $i|awk -F= '{print $2}'` 
  if [ $NUM -gt $DEFINE ];then 
     grep $IP /etc/hosts.deny > /dev/null 
      if [ $? -gt 0 ];then 
          echo "sshd:$IP:deny" >> /etc/hosts.deny 
      fi 
    fi 
done 
基本上,我看懂了,
有个疑问,写入/etc/hosts.deny,是否需要重新启动机器?
机器会自动读取已经改变的/etc/hosts.deny文件吗?
头像
lilydjwg
论坛版主
帖子: 4248
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: 机器需要重新启动吗?

#2

帖子 lilydjwg » 2018-01-25 21:54

不需要。这又不是 Windows,动不动重启。
回复