阅读量:155
在CentOS7中,可以通过修改SSH配置文件来禁用密码登录。以下是具体步骤:
-
使用root用户登录系统。
-
打开SSH配置文件
/etc/ssh/sshd_config,可以使用vim或者其他编辑器打开:
sudo vim /etc/ssh/sshd_config
- 在文件中找到以下两行代码:
#PasswordAuthentication yes
#PermitRootLogin yes
将这两行代码修改为:
PasswordAuthentication no
PermitRootLogin no
-
保存文件并退出编辑器。
-
重启SSH服务使配置生效:
sudo systemctl restart sshd
现在密码登录已经被禁用,你只能使用SSH密钥来认证登录到CentOS7系统。