Linux Labs

Networking / Stage 10 of 14 · step 8 of 9

Keep only the authorized SSH access

medium ~25 min
Not running Starting usually ~20 s
Report a problem

Situation

A separate practice SSH server runs on this machine — the lab-sshd.service unit. It listens on 127.0.0.1:2222 and reads its own settings file, /srv/ssh-lab/sshd_config; the system sshd has nothing to do with it. The service account deploy logs in through it with a key: the client is set up in ~/ssh-lab/config, and the login is ssh -F ~/ssh-lab/config training.

A security review found that the server lets in too many: with a password, through server questions and even as root.

Task

  1. The server lets people in with a key alone: neither a password nor server questions get anyone in.
  2. Root does not log in to this server — not even with the key that worked before — and the server offers no password.
  3. The new settings are in force: lab-sshd.service was restarted after the edit.
  4. deploy logs in with a fresh connection: ssh -F ~/ssh-lab/config training id -un prints deploy.
  5. Everything else is untouched: the other settings lines, the keys, the files in ~/ssh-lab and the system SSH.

Constraints

  • Edit values in /srv/ssh-lab/sshd_config as plain lines, without Include or Match.
  • Restart only lab-sshd.service; leave the system ssh.service and /etc/ssh alone.

The tools you need are already installed. There's no internet on this machine.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 5
  • Password, keyboard-interactive and root are denied; key-only access — not checked yet
  • The fixed configuration runs in a new lab-sshd start — not checked yet
  • A fresh deploy login with the supplied key succeeds — not checked yet
  • Root with its previously working key is refused; no password is offered — not checked yet
  • Other settings, keys and the system SSH are untouched — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…