Applicable to:
- Plesk for Linux
Question
How to prevent sign-in over SSH for accounts that have an empty password?
Answer
With the setting PermitEmptyPasswords yes, SSH lets an account that has an empty password sign in with no password at all. Any person who knows the name of such an account can get a shell on the server. To prevent this, set PermitEmptyPasswords no. This is the default value of OpenSSH.
Note: After this change, accounts with an empty password cannot sign in over SSH with a password. If such an account needs SSH access, set a password for it or set up SSH key sign-in for it first.
- Connect to the Plesk server via SSH.
-
Create a backup copy of the SSH server configuration file. If the value is also set in an included file, create a backup copy of that file in the same way:
# cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
- Set
PermitEmptyPasswords noin the SSH server configuration. The value can be in the/etc/ssh/sshd_configfile or in a file thatsshd_configincludes, for example a file in the/etc/ssh/sshd_config.d/directory. Change the value in each file where it is set. Also change it in eachMatchblock that setsPermitEmptyPasswords yes. To edit the file, use any text editor. -
Check the configuration for errors:
# sshd -t
Note: On Debian and Ubuntu, this command can show "Missing privilege separation directory: /run/sshd". In this case, create the directory with
mkdir -p /run/sshdand run the command again. -
Restart the SSH service.
For Plesk on CentOS / AlmaLinux / CloudLinux / RHEL:
# systemctl restart sshd
For Plesk on Debian / Ubuntu:
# systemctl restart ssh
-
Check the value that SSH uses:
# sshd -T
In the output, the line
permitemptypasswordsmust showno. If it showsyes, find the file that still setsyes, and go back to step 3.
Comments
Please sign in to leave a comment.