Search K
Appearance
Appearance
在配置文件
vim /etc/ssh/sshd_config添加以下内容
DenyUsers <用户名>例如
DenyUsers l然后重启
systemctl daemon-reload&&systemctl restart sshliu@SSH:/$ cat /etc/ssh/sshd_config | grep -i deny
DenyUsers l
liu@SSH:/$
exit
$ ^[[A^C
$
Connection to 172.20.19.2 closed.
root@tb4:~# ssh liu@172.20.19.2
liu@172.20.19.2's password:
Last login: Thu Aug 8 15:13:28 2024 from 172.20.19.100
$
Connection to 172.20.19.2 closed.
root@tb4:~# ssh l@172.20.19.2
l@172.20.19.2's password:
Permission denied, please try again.
l@172.20.19.2's password:
Permission denied, please try again.
l@172.20.19.2's password:可以看到,用户名liu是正常登录的,用户名l则无法登录