Systems Administrator

Case File: The Setting That Was Ignored

An administrator added PermitRootLogin no at the bottom of the SSH server configuration and believed the door was shut. The line was ignored: sshd uses the first value that it finds. Audit a configuration file the way the server reads it: first value wins, defaults for missing keywords, Match blocks kept apart, and a list of findings. Run the audit on files you cannot see. The file is generated for you alone.

50 min

Sabi Logistics · Remote 1

The Setting That Was Ignored

The scan says that root can still log in over SSH, although the team added a line to forbid it last month

Chidi Engineering manager ·

Chidi. The security scan of the build server says that root can log in over SSH with a password. I do not believe it. Last month one of our people added PermitRootLogin no to the file, and I saw the ticket closed.

I opened the file. The line is there, at the bottom. And three hundred lines above it, from the install, there is another PermitRootLogin yes. I am not an expert. Which one is the server using? Please write a check that reads the file the way the server reads it, and tells us what is really in force, so that we can run it on every machine we own.

The brief

What you need to know first.

  • First value wins. For most keywords, sshd takes the first value that it finds and ignores later ones. A line added at the end of the file does not change a setting that was already given above it. That is the opposite of what most configuration files do, and it surprises everybody once.
  • Match blocks. A Match line (for example Match User backup) starts a block of settings that apply only to those users or addresses, and it runs until the next Match line or the end of the file. The lines under it are not global settings: do not let them change the global values, but report if a Match block turns on PasswordAuthentication or PermitRootLogin.
  • Read the file. Strip each line; skip empty lines and lines that start with #. The keyword is the first word (case-insensitive), the value is the rest in lower case. Before the first Match line, keep the first value of each keyword in a dict; a later line with a different value is ignored_duplicate:KEYWORD (the same value again is no problem).
  • Defaults and findings (sorted, each once): root_login (PermitRootLogin is yes; missing means prohibit-password, which is fine); password_auth (not no; missing means yes); empty_passwords; max_auth_tries (above 4; missing means 6, so it is a finding); x11_forwarding; no_allow_list (no AllowUsers and no AllowGroups); match_allows_password; match_allows_root.
  • Fill in audit(lines), findings and n_findings. The checks run audit on files you cannot see: one where the safe line is first and an unsafe one is ignored, one where the unsafe line is first, and an empty file (all the defaults).

The lab gives you the data for this case, invented and generated for you alone. Today is 2026-11-09.

Preparing your data…

On a real system

The lab modelled the rules with a script. These are the commands that you would type on the real thing.

You want toTypeWhat you get
see what the SSH server will really usesudo sshd -Tevery setting after all the files and defaults, one per line
test a configuration file before reloadingsudo sshd -tprints an error if the file is wrong, and nothing if it is fine
see one setting in the files that sshd readsgrep -ri permitrootlogin /etc/ssh/sshd_config /etc/ssh/sshd_config.d/every line that sets it, in every file

Only run commands on systems that you own or have written permission to test.

🔒 The debrief unlocks when you close the case. Finish the lab above.

Write the SSH audit note

Write the note for the engineering manager: how sshd reads the file (the first value wins, Match blocks are kept apart, defaults for missing keywords), what your audit found and why each finding matters, why a line added at the end of the file did not take effect, and how to prevent it (a drop-in file that is read first, sshd -T and sshd -t, a second session when reloading, configuration management with an audit, key-only logins, an allow list, fail2ban and a firewall).

0 words

🧪 Want to practise this on your own computer? See how to set up your lab →

📝

Knowledge Check

1 of 4

A file says PermitRootLogin yes on line 10 and PermitRootLogin no on line 300. What does sshd use?

Report a problem

About: /lessons/case-the-ignored-setting