Home / Security

Security

Simple habits prevent most problems.

Laptop showing security settings next to Agenda VR3.

Update often

Apply security updates promptly, or enable automatic updates.

SSH keys

Use key-based login and disable password logins on servers.

Firewall

Expose only the services you need.

Least privilege

Do day-to-day work as a normal user, and use sudo only when needed.

Trusted sources

Prefer official repositories over random scripts.

Backups

Automatic, tested and stored off the machine.

Reduce the attack surface

A secure system usually starts as a small system. After installing a distribution or enabling a new feature, check what is actually running rather than assuming the defaults suit your setup.

On most systems, two quick checks tell you a lot:

  • ss -tulpn shows listening network services
  • systemctl --type=service --state=running shows active services
  • systemctl list-timers and crontab -l reveal scheduled jobs

This often turns up software you forgot was there: a print service on a headless machine, file sharing on a laptop, a development database listening on all interfaces, or an old web dashboard that was only meant for testing.

If a service is not needed, stop it and disable it so it does not come back on reboot. If it is needed only locally, bind it to 127.0.0.1 or a private address instead of exposing it to every network. That matters in particular for admin panels, metrics endpoints and databases. The Networking page covers the basics of interfaces, ports and addresses if you need a refresher.

It is also worth removing software you no longer use. Old language runtimes, test frameworks, sample web applications and remote access tools increase the number of packages to patch and the number of things that can go wrong. On desktop systems this is mostly housekeeping. On internet-facing systems it is part of hardening.

A simple habit helps here: after major changes, make a note of every service that should be reachable from another machine. If it is not on that short list, question why it is running. The less you expose, the less there is to defend. For package removal and service-related updates, see Packages.

Check logs before problems become incidents

Good logging will not stop an attack, but it will usually show the early signs: repeated login failures, a service restarting over and over, a new user account appearing, or a script failing silently after an update.

You do not need a full monitoring stack to get value from this. Start with a few commands you can run regularly:

  • journalctl -b for messages since the last boot
  • journalctl -p warning..alert for warnings and errors
  • journalctl -u ssh for SSH-related activity on systems that use that service name
  • last for successful logins
  • lastb for failed logins, if your system records them

Some distributions still write authentication events to /var/log/auth.log or /var/log/secure, so check both the journal and traditional log files when you are learning a system.

Look for patterns, not just dramatic errors. Ten failed logins from one address may be noise. The same failures across many accounts, or sudo attempts from a service user, deserve attention. So do new listening ports after an upgrade, unexplained time changes, or a daemon that keeps crashing and restarting.

Keep the machine clock correct so timestamps mean something, and make sure logs are readable only by the right users. If you are troubleshooting a security change, write down what you changed and when. That makes rollback much easier when you lock yourself out or break a dependency. The Troubleshooting page is useful when a hardening change has side effects.

Protect local data and secrets

A firewall and careful updates help, but they do not protect data on a stolen laptop, a misplaced handheld, or a discarded SSD. For portable systems, full-disk encryption is one of the most useful protections you can enable. It is especially relevant if the machine travels, is used in shared spaces, or stores mail, browser sessions, SSH keys or work documents.

Encryption is not a substitute for good session hygiene. If the device is unlocked, the data is available. Use an automatic screen lock, suspend carefully, and avoid automatic login on machines that may be left unattended.

Secrets on Linux often leak in ordinary ways rather than dramatic ones. Common examples include private keys with loose permissions, passwords embedded in shell scripts, and tokens left in world-readable config files or home directories shared through backups and sync jobs.

A few practical rules help:

  • keep sensitive files readable only by the owning account, often with chmod 600
  • avoid passing passwords directly on the command line, where they may appear in shell history or process listings
  • use separate accounts for separate people and tasks
  • review who can read application config files, cache directories and exported logs

The Users & permissions page covers the ownership and mode bits behind this.

When moving files between machines, prefer encrypted transports such as scp, sftp or rsync over SSH rather than older plain-text protocols. For removable media, remember that USB sticks and memory cards are easy to lose and easy to copy.

If you work with appliance-style systems or firmware images, be careful with hard-coded credentials. Anything baked into an image should be treated as recoverable by anyone who can read that image. Device-specific secrets and first-boot setup are safer than shipping the same password everywhere.