sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config && \sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \sshd -t && \systemctl restart ssh

🔍 命令说明:

  1. PasswordAuthentication yes 允许使用密码登录(默认可能是 no)。
  2. PermitRootLogin yes 允许 root 用户直接用密码登录。
  3. sshd -t 验证配置文件 。
  4. systemctl restart ssh 重启 SSH 服务,使配置生效。