CentOS7中怎么禁用密码登录

avatar
作者
猴君
阅读量:0

在CentOS7中,可以通过修改SSH配置文件来禁用密码登录。以下是具体步骤:

  1. 使用root用户登录系统。

  2. 打开SSH配置文件/etc/ssh/sshd_config,可以使用vim或者其他编辑器打开:

sudo vim /etc/ssh/sshd_config 
  1. 在文件中找到以下两行代码:
#PasswordAuthentication yes #PermitRootLogin yes 

将这两行代码修改为:

PasswordAuthentication no PermitRootLogin no 
  1. 保存文件并退出编辑器。

  2. 重启SSH服务使配置生效:

sudo systemctl restart sshd 

现在密码登录已经被禁用,你只能使用SSH密钥来认证登录到CentOS7系统。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!