Linux-密钥改成密码登录SSH为 root 设置密码
sudo passwd root修改 SSH 配置,允许密码登录(修改可以用 宝塔SSH的文件夹功能进入/etc/ssh找sshd_config复制到记事本,然后查找修改,更方便)
# 编辑 SSH 配置文件
sudo vim /etc/ssh/sshd_config找到以下配置项,修改为:
# 将 PasswordAuthentication 改为 yes
PasswordAuthentication yes
# 如果存在 ChallengeResponseAuthentication,也改为 yes(可能没有)
ChallengeResponseAuthentication yes
# 如果要允许 root 直接登录(可选)
PermitRootLogin yes说明:
PasswordAuthentication yes:允许密码登录
PermitRootLogin yes:允许 root 用户直接登录(如果需要的话)
重启 SSH 服务使配置生效
# Debian/Ubuntu 系统
sudo systemctl restart sshd