denyhosts不断添加我的IP

mal*_*lat 24 ssh

我试图解锁我正在做一些测试的IP.我已经按照网上的教程:

$ sudo /etc/init.d/denyhosts stop
$ sudo vim /etc/deny.hosts
[remove the last line where I can see my IP to clear]
$ cd /var/lib/denyhosts/
$ sudo vim *
[remove any occurences of my IP to clear]
$ sudo /etc/init.d/denyhosts start
Run Code Online (Sandbox Code Playgroud)

此时我的IP出现在/etc/deny.hosts中.我也尝试过:

$ cd /var/lib/denyhosts/
$ echo '123.456.789.122' >> /var/lib/denyhosts/allowed-hosts
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

$ echo 'my.ip.to.clear' >> /etc/hosts.allow
Run Code Online (Sandbox Code Playgroud)

不幸的是,hosts.deny始终优先,拒绝ssh连接,从日志文件中可以看出:

2月10日10:06:24 ks123456 sshd [22875]:拒绝连接123.456.789.122(123.456.789.122)

ref:debian/6.0.4,denyhosts 2.6-10

小智 34

这对Centos有用.按照下面的8个步骤,你应该很高兴.

  1. 停止DenyHosts

    # services denyhosts stop

  2. 从中删除IP地址 /etc/hosts.deny

  3. 编辑/var/lib/denyhosts/hosts并删除包含IP地址的行.保存文件.

  4. 编辑/var/lib/denyhosts/hosts-restricted并删除包含IP地址的行.保存文件.

  5. 编辑/var/lib/denyhosts/hosts-root并删除包含IP地址的行.保存文件.

  6. 编辑/var/lib/denyhosts/hosts-valid并删除包含IP地址的行.保存文件.

  7. 编辑/var/lib/denyhosts/users-hosts并删除包含IP地址的行.保存文件.

(可选)考虑将IP地址添加到/ var/lib/denyhosts/allowed-hosts

  1. 启动DenyHosts

    # services denyhosts start

  • 适合我.我没有得到的是为什么denyhosts首先阻止IP,以及为什么所述文件中列出的其他IP都不是! (2认同)

All*_*len 8

可以在此处找到删除denyhosts条目的说明:http://www.cyberciti.biz/faq/linux-unix-delete-remove-ip-address-that-denyhosts-blocked/ .在Ubuntu中,denyhosts数据文件位于/var/lib/denyhosts.

  1. 确保在denyhosts中没有表示IP地址域名的条目.
  2. 从/etc/deny.hosts(Uttntu的/etc/hosts.deny)中删除所有出现的IP地址和域名后,如果仍然无法登录,请查看身份验证日志: /var/log/auth.log 它可能会为您提供线索你的问题是什么.
  3. 如果您在服务器和客户端上运行Linux,则可能需要使用ssh-copy-id,这样您就不需要密码登录就可以防止将来使用错误的密码锁定自己.

我自己遇到了问题,因为我使用sftp在KDE上的Dolphin中保存了一个位置.Dolphin使用您当前的用户名尝试登录,将我的IP添加到hosts.deny文件中.


cri*_*ter 7

只需添加应始终有权访问该文件的IP:

/etc/hosts.allow
Run Code Online (Sandbox Code Playgroud)

该条目可能如下所示:

ALL: 30.20.10.0/24
Run Code Online (Sandbox Code Playgroud)

这样,即使最终/etc/hosts.deny也是如此,IP仍然可以访问.

心灵ALL 之前的IP,我看你忘了,你的echo发言.

参考文献:


小智 7

如果上面的说明没有帮助,可能denyhosts将ip添加到iptables防火墙.

iptables -L -n -v | grep xxx.xxx.xxx.xxx

如果你看到类似的东西:

0 0 DROP all -- * * xxx.xxx.xxx.xxx 0.0.0.0/0

从防火墙中删除所需的IP:

iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP

并重新启动网络以应用更改:

/etc/init.d/networking restart