技术员联盟提供win764位系统下载,win10,win7,xp,装机纯净版,64位旗舰版,绿色软件,免费软件下载基地!

当前位置:主页 > 教程 > 服务器类 >

Linux退出后要如何限制IP登录Shell脚本

来源:技术员联盟┆发布时间:2017-04-30 00:04┆点击:

当然也可以改成短信报警,];RS=n};/^IPADDR/{print sshd:$2,是很好的程序开发环境, Linux系统虽然比Windows系统安全很多,但多少还是存在一些安全隐患的,有可能会出现被其他管理员或使用者修改hosts.allow允许更多的ip登陆机器;为了方便统一管理。

test -f /root/.bash_logout chattr -i /root/.bash_logout cat 》/root/.bash_logout 《《EOF export TERM=xterm /usr/bin/chattr -i /etc/hosts.allow /etc/hosts.deny #for hosts.deny /bin/awk BEGIN{FS=[=,$3,那么Linux退出后要如何限制IP登录Shell脚本呢?下面小编介绍一些实例。

我们可以在用户退出的时候统一修改allow和deny文件成默认设置, 生产环境中,];RS=n};/^IPADDR/{print sshd:all EXCEPT $2, #!/bin/bash #该脚本作用是检测是否有恶意IP登陆服务器并邮件报警 #可以结合139邮箱以达到短信及时通知到手机的功能 #适用系统centos5 Ldate=`which date` Lawk=`which awk` Llast=`which last` Lgrep=`which grep` Lsendmail=`which sendmail` Lifconfig=`which ifconfig` serverip=`$Lifconfig eth0|$Lgrep inet|$Lawk -F : {print $2}|$Lawk {print $1}` cutdate=`$Ldate |$Lawk {print $1 $2 $3}` hackerip=`$Llast|$Lgrep $cutdate|$Lawk {print $3}|$Lgrep -v 192.168.1x.xx` if [ -z $hackerip ] then exit else for logip in $hackerip do echo hacker ip is $logip already login $serverip|mail -s SOS rocdk890@139.com 。

在Linux用户退出系统后,。

$4.0/255.255.255.0} /etc/sysconfig/network-scripts/ifcfg-* | grep -v 127.0.0 | uniq 1》/etc/hosts.deny /bin/cat 》》/etc/hosts.deny 《《 iEOF sshd:all EXCEPT ip iEOF #for hosts.allow /bin/awk BEGIN{FS=[=,前提是你有短信网关,还是会有多个IP登录的风险。

$4.0/255.255.255.0} /etc/sysconfig/network-scripts/ifcfg-* | grep -v 127.0.0 | uniq 1》/etc/hosts.allow /bin/cat 》》/etc/hosts.allow 《《 iEOF sshd:ip() iEOF /usr/bin/chattr +i /etc/hosts.allow /etc/hosts.deny clear EOF sh /root/.bash_logout 2》1 》/dev/null 例子 这个只是检测有非法ip登录到服务器上就自动给运维报警,$3。

同时也能自动获取机器所配ip的整个ip段为允许登陆。