About This Guide
This guide…This is a work in progress that continues to evolve as new security practices emerge and community members contribute.
What This Guide IS
- Focused on at-home Linux servers - All concepts apply to larger/professional environments, but those use-cases call for more advanced and specialized configurations that are out-of-scope
- Distribution agnostic - Works with most Linux distributions, though examples primarily use Debian-based commands
- Organized logically - Sections are ordered in a way that makes sense (e.g., securing SSH before installing a firewall)
- Easy to follow - Provides copy-and-paste code snippets that you can use directly (with minor modifications)
What This Guide IS NOT
- Not a Linux tutorial - Check Linux Journey if you’re new to Linux
- Not comprehensive security training - Doesn’t cover all aspects of system security (e.g., physical security is out of scope)
- Not a deep dive into tools - Covers bare necessities to get you started and make you hungry to learn more
- Not required to be followed in order - Though recommended, as some sections depend on previous ones
Approach
My Use-Case
There are many types of servers and different use-cases. While this guide aims to be as generic as possible, some things may not apply to all scenarios. Use your best judgment when going through this guide. To help put context to many of the topics covered, here’s the reference configuration:Hardware
- Desktop class computer
- Single NIC (network interface card)
Network
- Consumer grade router
- Dynamic WAN IP from ISP
- IPv4 for WAN and LAN
- NAT on the LAN
Access
- SSH access from remote locations
- Unknown computers and networks
- Friends’ houses, coffee shops, etc.
Security Goal
- Secure remote administration
- Protection from internet threats
- Defense in depth approach
If your use-case differs significantly (e.g., you have a static IP, multiple NICs, or only access from a known location), some recommendations may need adjustment.
Editing Configuration Files - For The Lazy
I am very lazy and do not like to edit files by hand if I don’t need to. I also assume everyone else is just like me. 😊 So, when and where possible, this guide providescode snippets to quickly do what is needed, like add or change a line in a configuration file.
How the Snippets Work
The code snippets use basic Linux commands:echo
Outputs text that can be redirected to files
cat
Concatenates and displays file contents
sed
Stream editor for find/replace operations
awk
Pattern scanning and text processing
grep
Searches for patterns in text
How these commands work in detail is out of scope - the
man pages are your friend if you want to learn more.Important Caveats
Not all changes can be automated with code snippets. Some changes require manual editing:- INI-style configuration files where context matters
- Complex multi-line configurations
- Files that require specific formatting
nano, vim, vi, etc.).
Before Using Snippets
Key Principles
Distribution Agnostic
This guide works with most Linux distributions, but there are some considerations:- Package managers differ - Examples use
apt(Debian/Ubuntu), but other distros useyum,dnf,pacman, etc. - File paths may vary - Check your distribution’s documentation if you encounter issues
- Default configurations differ - Some distros have different defaults
The guide is tested primarily on Debian. If you find something that doesn’t work on your distribution, contributions are welcome!
Security First
- Minimal installation - Only install what you absolutely need
- Defense in depth - Multiple layers of security
- Assume breach - Plan for what happens if one layer fails
- Keep updated - Security patches are critical
Practical Focus
This guide prioritizes:- Effectiveness - Does it actually improve security?
- Practicality - Can it be implemented by most users?
- Maintainability - Can you keep it running long-term?