Permissions and service hardening
Give each identity only the access it needs
A process needs directory search permission along the entire path and read permission on a file it serves. It need not own or write the website. A deployment owner can publish files and grant a dedicated service group read access; keep private files outside the root. The following synthetic permission inventory assumes the service belongs to webread and app secrets belong to another account. Check every parent directory before blaming the last file. Never apply recursive world-writable modes to fix a 403.
drwxr-x--- deploy webread /opt/bytemind/site-rw-r----- deploy webread /opt/bytemind/site/index.htmldrwx------ app app /opt/bytemind/private-rw------- app app /opt/bytemind/private/settingsProtect TLS keys and privileged listeners
A TLS private key must be readable by the process loading it, not by all users. A root master can load a restricted key before dropping worker privileges; an entirely non-root instance needs a narrowly scoped readable key. A high port avoids relying on low-port bind privileges in the lab. For a real low port, verify the OS capability policy or use a separately managed frontend; do not grant broad root powers. The inventory below is illustrative for a non-root TLS service with its own group; directory traversal and renewal ownership also matter. Never copy real keys into a course.
drwxr-x--- root webread /opt/bytemind/tls-rw-r----- root webread /opt/bytemind/tls/server.key-rw-r--r-- root root /opt/bytemind/tls/server-chain.pemHarden a custom service deliberately
A systemd unit is an execution contract. For a dedicated foreground Nginx master, use a matching process model instead of treating a forking package unit as interchangeable. The sample unit in the lab uses Type=exec, a dedicated account, RuntimeDirectory and restrictive filesystem settings. NoNewPrivileges limits privilege acquisition by later execution; ProtectSystem=strict makes most of the filesystem read-only inside the unit but required runtime and log directories must remain writable. PrivateTmp isolates temporary namespaces, not networking. Validate the complete unit on its target systemd release and test every necessary file and socket. This fragment is not a drop-in for a package service.
[Service]User=bytemind-webGroup=bytemind-webNoNewPrivileges=yesProtectSystem=strictPrivateTmp=yesRuntimeDirectory=bytemind-nginxLogsDirectory=bytemind-nginxInvestigate mandatory policy and network boundaries
SELinux and AppArmor impose restrictions separate from ordinary Unix mode bits. A file can be readable according to its owner/group and still be denied by policy; a permitted socket can be blocked by a firewall. Review the applicable policy and logs with the system administrator, confirm the expected file labels or profile rules and make a narrow reviewed correction. Do not disable mandatory access control to make an example work. The sample observations are synthetic and show different layers; the Linux track covers the distribution-specific tools in depth.
file mode check: allowedmandatory access policy: denied → review label/profilebackend listener: loopback onlypublic firewall: backend port not permittedCheck Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Permissions and service hardening
Review Unix permissions, TLS key access, systemd sandboxing and mandatory access controls for a least-privilege Nginx service.
A worker can read index.html but cannot search its parent directory. What should you review?
Which account needs access to a TLS private key?
What does ProtectSystem=strict require you to consider?
Ordinary mode bits allow access but SELinux denies it. What is the next action?
What is a benefit of a high port in an unprivileged lab?