Ultimate.Hosts.Blacklist icon indicating copy to clipboard operation
Ultimate.Hosts.Blacklist copied to clipboard

sshd connection problems with superhosts.deny & hosts

Open georgengelmann opened this issue 3 years ago • 13 comments

I tried the superhosts.deny and the hosts file on a Debian 10 Server. Now I have locked myself out. I tried different ssh clients & VPN to check, but the server is causing the connection problem.

Linux ssh error: "read: connection reset by peer" Putty / Kitty error: "Software caused connection abort"

georgengelmann avatar Jul 16 '20 21:07 georgengelmann

Hey @georgengelmann have you checked that your own IP address isn't in the list??

It could be related to this issue https://github.com/mitchellkrogza/Ultimate.Hosts.Blacklist/issues/580#issuecomment-626152267 by @ZerooCool

Alternatively if you dare you can sent me the login info to the server over keybase.io and I can see if I can help you, the case is the error responses you get easily can be a unstable connection, rather than a actual server issue.

A tremendous huge deny.hosts file isn't usual a problem on *nix systems

spirillen avatar Jul 16 '20 21:07 spirillen

have you checked that your own IP address isn't in the list??

Yes and I tried connecting via VPN

georgengelmann avatar Jul 16 '20 22:07 georgengelmann

That one could easily be in the list as well :smirk: as many VPN's are listed there, as the criminals abuses them.

Do you have a friend or someone else in your neighborhood you could give a quick visit to lent there internet to try to connect from there?

It is a hunch, but I feel it is in your IP you should seek the problem

spirillen avatar Jul 16 '20 23:07 spirillen

I searched for my IP in the hosts.deny file and the IP file and it's not there.

I can connect to other ssh servers from here.

I also tried to connect to my server from another server.

georgengelmann avatar Jul 16 '20 23:07 georgengelmann

OK that's bad then :unamused: is it a VPS server with a little number of vRam and vCPU? if, try to rise the values of those as a list of this size would require at least >2GB Ram and >2 vCPU otherwise the timeout would uccure because it can cashed the list and it is taking to long to scout true the list for every connection attempt.

spirillen avatar Jul 17 '20 09:07 spirillen

Technically, Linux can handle the hosts file, but the superhosts.deny is a problem for SSH (I could login via an admin panel)

sudo rm -rf /etc/hosts.deny => sshd connection works again

The affected system has 110GB RAM and 24 CPU cores.

georgengelmann avatar Jul 17 '20 13:07 georgengelmann

That's one big moth..... But something else that stroked me....

Why on earth isn't you using NFTABLES on a d.10 box?

NfTables can handle both IPv4/IPv6 AND domain names!!! The trick is to read the data in as array to keep it fast, not as in IPTables as one record = one rule

But the best tool you can chose to that box is defiantly powerdns.com recursor https://www.powerdns.com/recursor.html and then use the RPZ zones https://www.mypdns.org/w/rpzlist/ There is also a converted edition of the UHB list on GL https://gitlab.com/my-privacy-dns/external-sources/hosts-sources/-/tree/master/data/mitchellkrogza

GitLab
Script to keep lists of external hosts sources up to date in a raw `domain.tld` format for easier manipulating date from external sources

spirillen avatar Jul 17 '20 15:07 spirillen

Is it easy to configure? Download + add RPZ file?

georgengelmann avatar Jul 17 '20 17:07 georgengelmann

Depends... how well do you understand the concept of the DNS hierarchic?

But yes, it's easy and rather self maintained :smile:

If you chooses to go for the pdns-recursor, then you'll find a lot of help on there IRC channel almost from the install level. (For my opinion the pdns recursor is by far the best, as it is build to manipulate queries by lua scripting)

For getting the idea of how the records is written you can look at this cheat-sheet I made. https://mypdns.org/mypdns/support/-/wikis/RPZ-record-types

This is my /etc/powerdns/recursor.lua

-- Load DNSSEC root keys from dns-root-data package.
-- Note: If you provide your own Lua configuration file, consider
-- running rootkeys.lua too.
dofile("/usr/share/pdns-recursor/lua-config/rootkeys.lua")

rpzMaster(
        {"95.216.166.138", "195.201.225.97"},
        "rpz.urlhaus.abuse.ch",
        {refresh="360", axfrTimeout="600", 
        zoneSizeHint="900",
        dumpFile="/var/lib/pdns-recursor/urlhaus",
        seedFile="/var/lib/pdns-recursor/urlhaus"}
)

rpzMaster(
        {"[2a01:4f9:c010:2166::53]:53","[2a01:4f8:1c1c:abe4::53]:53"},
        "whitelist.mypdns.cloud",
        {refresh="600", axfrTimeout="600"}
)

rpzMaster(
        {"[2a01:4f9:c010:2166::53]:53",
        "[2a01:4f8:1c1c:abe4::53]:53"
        },
        "rpz.mypdns.cloud",
        {refresh="120",
        axfrTimeout="600",
        zoneSizeHint="650000"}
)

rpzMaster(
        {"[2a01:4f9:c010:2166::53]:53",
        "[2a01:4f8:1c1c:abe4::53]:53"
        },
        "adware.mypdns.cloud",
        {refresh="120",
        axfrTimeout="600",
        zoneSizeHint="650000"}
)

rpzMaster(
        {"[2a01:4f9:c010:2166::53]:53","[2a01:4f8:1c1c:abe4::53]:53"},
        "typosquatting.mypdns.cloud",
        {refresh="600", axfrTimeout="600"}
)

rpzMaster(
        {"[2a01:4f9:c010:2166::53]:53","[2a01:4f8:1c1c:abe4::53]:53"},
        "drop.ip.dtq",
        {refresh="120"}
)

rpzMaster(
        {"95.216.166.138:5353", "195.201.225.97:5353"},
        "pirated.mypdns.cloud",
        {refresh="120"}
)

You find a somewhat good documentation at https://docs.powerdns.com/

For installation you should go with the PDNS Repo https://repo.powerdns.com/#debian

And when you are ready to switch, kill the forkedup (týes spelling issue here :imp: ) systemd-resolv daemon as it is using the default port 53

And the last advice I can think of up-front: DO MAKE A LOCAL WHITELIST.....

spirillen avatar Jul 17 '20 18:07 spirillen

Hi @georgengelmann How did it go with this question? Did you convert to a local resolver or did you stick to the host.deny file?

spirillen avatar Nov 17 '20 15:11 spirillen

Yes, I was also locked out using the deny list. I'm using fail2ban which seems to do a good job and you can create permanent jails.

amastelek avatar Feb 11 '21 14:02 amastelek

Is this still an issue? I can't reproduce this on my network components... 😞

funilrys avatar Jul 09 '21 21:07 funilrys

Is this still an issue? I can't reproduce this on my network components... disappointed

Have you tested on a slow 5400 rpm spinel disk.... disk I/O is in play on both hosts and deny/allow?

spirillen avatar Jul 10 '21 08:07 spirillen