On-call locked out of the bastion OPS-802

Open2 versionsLinux · Hard · Fix · about 35 min ·Linux, root

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Teo Marin opened OPS-802 at 15:30SEV-3

Since the directory migration, Mara and Teo cannot SSH into the depot bastion. The deploy robot still can. Mara is on call tonight.

The bastion is the only way into the depot network from outside. If on-call cannot reach it, tonight's pages cannot be answered.

"Keys only, no passwords. Contractors stay out. And do not list people one by one in sshd_config, access follows groups or it rots." (Priya)

sshd writes the reason for every refused login to its log. It is usually more specific than "Permission denied".

Your task

Read why sshd refuses Mara, change the policy so the on-call group can log in with keys, validate it with sshd -t, and reload sshd. Keep passwords off, keep root out, and keep contractors out.

On the machine

  • /var/log/sshd.log
  • /etc/ssh/sshd_config and its drop-ins
  • id mara, id noor
  • Test keys in /srv/keyvault/

Timeline

SatDirectory migration moves on-call engineers from oncall to oncall-sre.
15:10Teo: "Permission denied (publickey)" on the bastion.
15:30OPS-802 opened. Mara's on-call shift starts 18:00.

Done when

  1. Mara and Teo log in with their keys, and the deploy robot still does.
  2. Noor, passwords, and root stay locked out.

Hints

Hint 1

sshd usually logs the exact reason a user was refused. Check /var/log/sshd.log.

Hint 2

`sudo sshd -T -C user=mara,host=localhost,addr=127.0.0.1` prints the policy as sshd applies it to Mara: her allowed groups, and where it looks for her keys.

Hint 3

Compare that with `id mara` and with the files that exist. Edit the drop-in under /etc/ssh/sshd_config.d/ or put what is missing in place, then `sudo sshd -t`.

Hint 4

A running sshd rereads its configuration on SIGHUP.

Show the solution

Read `/var/log/sshd.log` for the reason Mara was refused, and `sudo sshd -T -C user=mara,host=localhost,addr=127.0.0.1` for the policy as applied to her. Either the allow-list names `oncall`, while on-call engineers are now in `oncall-sre` (change the drop-in to `AllowGroups oncall-sre deploy`), or the allow-list is right but sshd reads keys from `/etc/ssh/authorized_keys/%u` and the migration copied only the robot's key there (install Mara's and Teo's public keys from `/srv/keyvault/` as root-owned, mode 644 files). Run `sudo sshd -t`, reload with `sudo pkill -HUP -x sshd`, and test Mara (allowed) and Noor (refused).