Skip to main content

Unit 6 路 Services, Ports, and Software 路 Lesson 16 of 25

SSH Settings

The handful of lines in the SSH settings file that are worth points.

Hardening the service you keep

SSH is almost always allowed to stay, so this is an editing job rather than a removal job. One file:

sudo nano /etc/ssh/sshd_config

Use Ctrl+W to search for each setting below, and change it to the value in the middle column. If a line starts with a #, that means it is switched off, so delete the # as well.

Find this lineSet it toWhy it is worth points
PermitRootLoginnostops anyone logging straight in as the top account
PermitEmptyPasswordsnootherwise an account with no password becomes remote access
X11Forwardingnonot needed, so it is just extra exposure
MaxAuthTries3slows down password guessing
LoginGraceTime60closes half-open connections

Save with Ctrl+O, Enter, then Ctrl+X.

馃挕 Check there is only one copy of each line. If the same setting appears twice in the file, the machine may not use the one you edited. After changing a line, press Ctrl+W and search for it again to make sure there is not a second one further down.

Apply the change

sudo systemctl restart ssh

If you want to be careful, check your typing first:

sudo sshd -t

That says nothing at all if the file is fine. If it complains, fix the file before restarting, because a service that will not start is a service nobody can log into.

Try it yourself

sudo nano /etc/ssh/sshd_config     # Ctrl+W to find each setting in the table
sudo sshd -t                        # silence means it is fine
sudo systemctl restart ssh

Do this lesson for real

With a free account you get the terminal, the challenges and the checks that go with every lesson in CyberPatriot Linux: Tokyo Jujutsu High, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.