1.利用 cloud-init脚本来开启root账号密码登录
1
2
脚本如下!

#!/bin/bash
echo root:password |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

默认密码是: password
登录后一定要修改密码!命令:passwd


2.使用密钥登录系统以后
执行如下命令

sudo -i
passwd

按提示刷入密码,重复输入密码。
接着输入

echo root:vipkj.net |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

重启sshd服务

sudo service sshd restart