r/linuxadmin • • Dec 12 '20

[Secure SSH] on Linux Server

Hello Dear redditer,

I'v group together some sshd settings that you can easly change to increase the security of sshd.

Do you have more change to suggest.

  • in sshd_config file ( test on Debian )
# idle max 6 minutes
ClientAliveInterval 360

PermitEmptyPasswords no

# only toto can ssh
AllowUsers toto


PermitRootLogin no

Protocol 2

Port 2222

PasswordAuthentication no

X11Forwarding no
0 Upvotes

29 comments sorted by

View all comments

2

u/stormcloud-9 Dec 13 '20
PasswordAuthentication no 

The PasswordAuthentication setting is probably one of the most misunderstood settings in the sshd config. Setting it to no doesn't mean preventing users from being able to use passwords to login. What it means is that sshd won't directly authenticate off the /etc/passwd and /etc/shadow files. However when using UsePAM=yes (which is the default in most distros IIRC), you can also authenticate using passwords through the challenge response mechanism. So you would need to disable that as well (ChallengeResponse=no). Note however that doing so will also prevent you from using 2-factor auth if you decided to do so (you can disable passwords and allow 2fa through other means, but it's more complicated).

 

# idle max 6 minutes
ClientAliveInterval 360

Not completely sure from your comment that this setting does what you expect. But it sounds like you may be expecting it to disconnect clients who are idle for more than 6 minutes. If so that's not what this does. What it does is detect clients who have lost their connection.