Denyhosts杀死ssh,denyhosts文件包含奇怪的字符

我们今天早上注意到,我们无法使用SSHlogin到我们的服务器。 我们的服务器提供商然后在ram上安装了一个最小的Linux。 安装好磁盘和chroot后,我暂时停止了denyhosts,当我进入hosts.deny文件清除我们的IP地址时,我们看到以下内容。 这究竟是什么?

# DenyHosts: Sat Jan 28 05:01:43 2017 | sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ # DenyHosts: Sat Jan 28 05:01:43 2017 | sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ # DenyHosts: Sat Jan 28 05:23:14 2017 | sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ # DenyHosts: Sat Jan 28 05:23:14 2017 | sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ sshd: ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@$ 

另外,当我给命令,iptables -L,我得到以下。 我想清除iptables规则:

 iptables -L libkmod: ERROR ../libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/4.8.15/modules.dep.bin' iptables v1.4.14: can't initialize iptables table `filter': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. 

这就是我如何根植于环境:

  mount --bind /proc /mnt/proc mount --bind /dev /mnt/dev mount --bind /sys /mnt/sys chroot /mnt 

谢谢。

更新

  modprobe filter modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.8.15/modules.dep.bin' modprobe: FATAL: Module filter not found in directory /lib/modules/4.8.15 

更新

日志

 Jan 30 02:39:34 HOSTNAME sshd[6483]: refused connect from 112.85.42.18 (112.85.42.18) Jan 30 02:40:18 HOSTNAME sshd[6495]: warning: /etc/hosts.deny, line 64: missing newline or line too long Jan 30 02:40:18 HOSTNAME sshd[6495]: warning: /etc/hosts.deny, line 64: all the subsequent rules will be ignored Jan 30 02:40:18 HOSTNAME sshd[6495]: refused connect from 112.85.42.18 (112.85.42.18) Jan 30 02:40:57 HOSTNAME sshd[6504]: warning: /etc/hosts.deny, line 64: missing newline or line too long Jan 30 02:40:57 HOSTNAME sshd[6504]: warning: /etc/hosts.deny, line 64: all the subsequent rules will be ignored Jan 30 02:40:57 HOSTNAME sshd[6504]: refused connect from 112.85.42.18 (112.85.42.18) Jan 30 02:41:37 HOSTNAME sshd[6519]: warning: /etc/hosts.deny, line 64: missing newline or line too long Jan 30 02:41:37 HOSTNAME sshd[6519]: warning: /etc/hosts.deny, line 64: all the subsequent rules will be ignored Jan 30 02:41:37 HOSTNAME sshd[6519]: refused connect from 112.85.42.18 (112.85.42.18) 

看起来像您的ISP提供的最小安装内核与实际系统中的内核不同。 然后,它会尝试为iptables加载filter模块,并且由于您的chroot环境没有用于您的内核版本的模块而无法加载。

尝试在使用modprobe filterinputchroot之前加载filter模块。 希望最小的系统有可用的filter模块。

什么来到DenyHosts条目, ^@是空字节。 也许你的日志文件包含空字节由于某种原因,而不是IP地址,这就是为什么denyhosts将这些添加到规则。

另一种方法是在sshd或denyhosts中有一些导致空字节出现的错误。

如果有空字节,你可以检查你的日志文件。 如果是,那么sshd将它们输出到那里,拒绝主机只是复制它们,这意味着sshd有问题。 如果日志文件包含正常的条目,那么该错误是在sshd。