What’s the point of this if SSH key and Wireguard encryption offer comparable levels of security and it’s not like you can expect an attacker to be able to crack either? What are common use cases for Wireguard?
SSH is pretty secure by itself, if you follow all the guidelines (for example, disable password login, disable all logins for users that don’t need this access (like users services create when you install them) etc)
The use case for Wireguard is being a VPN. When you connect via Wireguard is just like if you are connected directly to the same network of your server. Like, if I traceroute the IP of my server through Wireguard, it just one hop away:
traceroute to 10.11.12.1 (10.11.12.1), 30 hops max, 60 byte packets
1 server.vpn (10.11.12.1) 221.807 ms 221.809 ms 221.784 ms
Also I’m on the same network of the other Wireguard clients, so my mobile phone can talk directly to my desktop computer even when I’m away from home. This is what a VPN is used for, make you a Virtual Network that is Private.
Should you run all typical services over Wireguard then or are there cases where you shouldn’t?
Depends. If I run my regular webserver over Wireguard, well, nobody will be able to see my website! But for example, my Jellyfin server is only behind Wireguard, there is no need to it be exposed to the entire internet. You run things behind Wireguard if you want them to be private.
Does this make stuff like Fail2ban/Crowdsec redundant (if I understand correctly, Wireguard uses UDP so won’t will only respond to unwanted connections)? Would Fail2ban/Crowdsec offer any benefits for ports that are not opened?
If you put a service behind Wireguard (or any other VPN) yes, fail2ban and similars will be redundant for that service. But you could enable Wireguard to crete logs and configure fail2ban to block IPs that attempt to connect but don’t provide a correct handshake. It will appear in the logs like this:
Sat Mar 6 20:41:31 2021] wireguard: wg0: Invalid handshake initiation from 203.0.113.2:51820
Never saw anyone doing this, thou.
Are there any other general rules to improve a firewall besides the default of denying all incoming connections except required ports?
A simple firewall like UFW will just allow you to block ports. But you can improve with other software too. The firewalls that perform DPI (Deep Packet Inspection) for example can detect certain traffic even if not using standard ports. So lets say you let your SSH only behind a Wireguard and install a DPI Firewall that is configured to block SSH connections on the public IP. And lets say you got a backdoor that creates an SSH server on a random port. The moment an SSH packet arrives, the DPI firewall will notice it and block. I never used such software so I can’t help with this one, besides knowing it exists.
One thing I noticed happening to my webserver is that several bots try to look for vulnerabilities in some web software. I get several hits on /wp/admin and other well know paths that of course return 404 errors. I configured fail2ban to jail the IPs that try to do that. A regular firewall can’t do it because I would be able to only open or close the 443 port. Fail2ban on the other hand can keep an eye on my webserver logs, and include firewall rules to block those IPs on the fly, and also keep a tally of what is blocked and for how long, to remove the blocks after a while.