Linux Labs

Networking / Stage 10 of 14

SSH — trusting the server and logging in with a key

Not running Starting usually ~20 s
Leave the lesson

Step 8 of 9 · lab · 25 minmedium

Keep only the authorized SSH access

A dedicated SSH server on 127.0.0.1:2222 lets in too many. Leave key-only access for deploy, deny root and check a fresh connection.

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.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

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

The machine is starting

Hints

0 of 3

Lab goals

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

Lab goals

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