ssh disable users code example

Example: disable ssh login for user

# To deny SSH access to specific user called “sk”, edit sshd_config file:
$ sudo vi /etc/ssh/sshd_config

# Add/edit the following line in sshd_config file.
DenyUsers sk

# Deny SSH access to multiple users, specify the usernames with space separated as shown below.
DenyUsers sk ostechnix

# Deny SSH access to an entire group, for example root, add:
DenyGroups root

# Save and quit the ssh config file. Restart ssh service to take effect the changes.
$ sudo systemctl restart sshd