如何允许 Root 用户使用密码登录

在某些操作系统中,默认禁止 root 用户使用密码登录;要更改这一点,您需要通过本地控制台编辑 SSH 守护进程的配置文件。

具体来说,检查目录 /etc/ssh/sshd_config.d/*.conf 中的配置文件,将 PermitRootLogin no 替换为 PermitRootLogin yes,并将 PasswordAuthentication no 替换为 PasswordAuthentication yes

如果该目录为空,则需要创建一个新文件并填入以下内容

$ sudo tee /etc/ssh/sshd_config.d/60-cloudimg-settings.conf<<EOF
PermitRootLogin yes
PasswordAuthentication yes
EOF

如果该目录不存在,则必须将以下内容添加到主配置文件的末尾

$ sudo echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
$ sudo echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config

然后重启 SSH 守护进程或重启虚拟机

$ sudo systemctl restart ssh

或(取决于操作系统)

$ sudo systemctl restart sshd
评分: 1 Star2 Stars3 Stars4 Stars5 Stars (8 次评分,平均 4.50)
Loading...