直接复制执行
#!/bin/bash
echo root:Passwd |sudo chpasswd root
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo reboot
更详细的步骤:
获取权限
sudo -i
然后编辑
nano /etc/ssh/sshd_config
查找 PermitRootLogin prohibit-password
(可能在注释里面)改成 PermitRootLogin yes
查找 PasswordAuthentication no
改成 PasswordAuthentication yes
CTRL + O
然后 ENTER
保存
nano /etc/ssh/sshd_config.d/*
修改或者添加 PasswordAuthentication no
改成 PasswordAuthentication yes
service sshd restart
添加密码
passwd
添加密码之后,删除key(注意备份),reboot
之后使用root和密码登录