切换为 root 用户
sudo -i
为 root 用户创建密码,输入两次
passwd root
修改 /etc/ssh/sshd_config 文件
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
重启 ssh 服务
systemctl restart sshd
以上方法在 ubuntu 操作系统上存在问题,究其原因为 ubuntu 操作系统中的 /etc/ssh/sshd_config 文件在 12 行 Include /etc/ssh/sshd_config.d/*.conf 文件
直接注释掉这一行即可
sed -i '/^Include \/etc\/ssh\/sshd_config.d\/\*\.conf/s/^/#/' /etc/ssh/sshd_config
systemctl restart sshd
3890






