SSH链接服务器,进入后使用命令 切换root权限
sudo -i
切换为root用户后输入下面的命令修改root密码登录(下面中文换成你的密码)
echo root:你设置的密码 |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 service sshd restart
如果仍失败,注释/etc/ssh/sshd_config文件中的
Include /etc/ssh/ssh_config.d/*.conf
如果重启sshd时提示
Failed to restart sshd.service: Unit sshd.service not found.则输入下面的代码再重启
systemctl enable ssh.service