The server settings live in sshd_config, but what the file says is not always what applies. The server itself prints the values it ends up with.
| Line | What it decides |
|---|---|
PasswordAuthentication |
password login |
KbdInteractiveAuthentication |
login with questions from the server — usually about a password too |
PubkeyAuthentication |
key login |
PermitRootLogin |
whether root may log in |
AuthenticationMethods publickey |
of all methods only one is left — the key |
sudo sshd -t -f file checks the file for errors, sudo sshd -T -f file prints every value the server will use.
Which value applies
Password login seems to be turned off in the practice server's /opt/ssh-lab/sshd_config. Find the password lines in the file, then ask sshd itself which values it applies.
First, predict
The file has two lines: PasswordAuthentication yes higher up and PasswordAuthentication no further down. Which value applies?
Now start the exercise, run the command and compare your prediction with the output.
If a line is repeated, sshd takes the first one. So you edit the line that is already there: a new line at the end of the file changes nothing.
The server reads its settings file when it starts — unlike authorized_keys, which it reads at every login. The order for a change: edit the file, check it with sshd -t, restart the server and log in with a fresh connection.
A fresh login is needed after the change too: a session that is already open passed its check earlier and says nothing about the new settings.
You turned passwords off in sshd_config and restarted the server. An earlier session as deploy still works. What does that prove?
-
sudo sshd -t -f filelooks for errors in the file. An open session does not read it. -
sudo sshd -T -f fileprints the value in force: thepasswordauthenticationline. -
That session passed its check before the change. A fresh login shows how the server lets people in now:
ssh training id -un.
An open session passed the login checks earlier, and the change does not touch it. Three commands confirm the change: sshd -t, sshd -T and a fresh login.