密钥登录服务器执行以下命令:
sudo -i
passwd //设置密码
vi /etc/ssh/sshd_config
PermitRootLogin yes //默认为no,需要开启root用户访问改为yes
PasswordAuthentication yes //默认为no,改为yes开启密码登陆
vi .ssh/authorized_keys //删除ssh-rsa之前所有内容
systemctl restart sshd
GCP:
sudo sh -c 'echo "root:密码" | chpasswd && sed -i "s/PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && sed -i "s/#PasswordAuthentication yes/PasswordAuthentication yes/" /etc/ssh/sshd_config && apt update && apt upgrade -y && service ssh restart'
以上命令仅在Ubuntu测试!