Due to some security reason, you may require to block certain user SSH access to Linux box.
Edit the sshd_config file, the location will sometimes be different depending on Linux distribution, but it’s usually in /etc/ssh/.
Open the file up while logged on as root:
vi /etc/ssh/sshd_config
# vi /etc/ssh/sshd_config Insert a line to end of the config file:-
DenyUsers username1 username2 username3 username4
DenyUsers username1 username2 username3 username4 Save it and restart SSH services. Basically username1, username2, username3 & username4 SSH login is disallowed.
Run below command to restart the same:-
systemctl restart sshd
# systemctl restart sshd The requirement has been done. Please take the ssh from that users and your will get error " Access"Access Denied"
Thank You