Hi there,
I've been reading up on selfhosting for a couple of weeks now and I got my feet wet with a couple of things.
However, before really getting serious with it, I feel I need to get down the basics and make sure that my server will not end up a security hazard. My final goal would be to self-host my socials (Mastodon, Lemmy, Matrix) - just for myself.
What basic security do I need to have in place, considering these services? I'll be running this on a VPS and so far I consider the following: disable password login (login with ssh key only) then set up nginx, fail2ban, and a basic firewall. I'd try to close all ports that are not required for the services I run. I'll also change ssh port from 22 to something else and close port 22 as well.
Would this be a sufficient basis, or am I missing something crucial?
Changing the port seems like a pointless step, just disallow access from everywhere and allow only from select IPs. Port scanners will scan all open ports and will detect that it's ssh, regardless of port number.
If OP just wants to use it himself, a good idea might be to setup a VPN service and only allow the other services to be used from the VPN. That can be done with wire guard and a reverse proxy for example.
While I do completely agree, changing ports is more about getting rid of low-hanging fruit so some script kiddie doesn't get into 22. But again I do agree with everything you said.
Changing the default port isn’t any more secure, but you’ll cut down on access attempts which will take some load off of your VM. It’s something that could be worth doing if you’re running a very cheap VPS.
It's well worth it for this reason alone. Unless you're running a honeypot, getting that noise out of your access logs can provide more actionable data to work with for more persistent threats.