Linux中禁止root用户通过ssh远程登陆

您所在的位置:网站首页 linux限制ssh登录 Linux中禁止root用户通过ssh远程登陆

Linux中禁止root用户通过ssh远程登陆

2024-03-20 22:57| 来源: 网络整理| 查看: 265

实现方式:修改服务端/etc/ssh/sshd_config配置文件

1、找到/etc/ssh/sshd_config文件后修改其中的#PermitRootLogin yes为PermitRootLogin no 2、重启sshd服务

[root@villainc ssh]# systemctl restart sshd

补充:

设置只公私钥对登陆后,使用口令登录将被禁止

1、若要设置只允许以公私钥对的方式登陆就需要设置为PermitRootLogin without-password

#这里模拟口令登录失败,需要先删掉服务端的ssh登录授权文件authorized_keys文件 rm -rf ~/.ssh/authorized_keys #root用户再次使用口令登录将被拒绝 [root@hsc .ssh]# ssh [email protected] [email protected]'s password: Permission denied, please try again. [email protected]'s password:

2、同样设置所有用户是否允许口令登录设置PasswordAuthentication,设置后也需要重启sshd服务systemctl restart sshd



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3