How to restrict user logins to SSH
If we want to allow SSH login only to specific users, we need to edit the SSH configuration file.
nano /etc/ssh/sshd_config
At the end of the file, we add the AllowUsers line and a space-separated list of usernames. For example, if we have users kate and dave and we want them both to have access to SSH.
AllowUsers kate dave
Restart the SSH service and now only the specified users will log in.