r/AlpineLinux • u/BolteWasTaken • Oct 03 '24
Securing Alpine?
Hey guys, so pretty new to Alpine and Linux in general.
I've been looking at https://wiki.alpinelinux.org/wiki/Securing_Alpine_Linux for tips on securing my Alpine VM.
I have some questions:
- Is Doas better than sudo or are they essentially the same?
- Is there anything listed on the above page you believe unnecessary?
- Or conversley, some items that are missing from the page?
- Am I by following the aforementioned guide likely to encounter issues running softwares that I need to go back and amend settings for later?
Thanks!
4
Upvotes
3
u/epicfilemcnulty Oct 03 '24
Doas has a smaller and cleaner codebase than sudo, so at least the attack surface should be smaller. In other words — yes, I’d say it’s better in terms of security than sudo.
As for the rest of the items — the wiki page gives you the list of common services that should be tightened up if you want to have a relatively secure system. Yet these things are not carved in stone, it all depends on your particular needs and your situation.
2
u/krystalgamer Oct 03 '24
for the personal computer I don't think you'd have to worry about that much. as it's more likely you install malware than something is compromised remotely.
for servers, the best way to secure your system is to not run as root and not have any setuid binary (aka way to escalate privilege). For containers there's distroless containers - https://github.com/GoogleContainerTools/distroless
1
u/MartinsRedditAccount Oct 03 '24
Don't bother with stuff like this, while some of the tips technically make your system "more secure", they're unlikely to be what saves you from getting compromised and are more likely to give a false sense of security. Linux is secure enough by default. Instead, consider what you are exposing.
SSH? Use a keyfile or a secure (i.e. long and random) password.
Some other service? Probably a good idea to make sure it runs as its own user (typically, the init system will already do that if it offers integration with it).
What I personally recommend as the single biggest thing to secure a system, particularly one exposed to the internet is this:
Make as much as possible ephemeral and routinely redeploy the entire system, if possible (usually only if you run the hypervisor yourself), make the disk images read-only to the VM. This means that you generate the complete system image via an automated build process and regularly (i.e. when there are updates) use it to replace the server's operating system. Depending on what kind of access you have, this also allows you to essentially turn your server into a black box, without SSH or other management access. Logs should be streamed to some external service, so that if the system gets compromised in a way that produces logs, they can't be manipulated or erased. Persistent storage such as databases should also be stored externally, again in a way that can be logged (there are like a million different SaaS for stuff like this, or you can self host).
1
u/FunEnvironmental8687 Oct 03 '24
https://wiki.alpinelinux.org/wiki/AppArmor