将下面代码中的第一句中的muyijiang改为自己将要设置的密码。
否则默认root密码为muyijiang
创建实例的时候,点击添加启动脚本,将下列代码复制进去(注意更改root密码)。

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

对于EC2GCE等机器也可以使用.
不能添加代码的机器,可以登录进ssh,再执行上面的代码。
也可以开启root登陆。
以上代码在Debian/Ubuntu/Centos上通过测试。
其他发行版自行测试。

原文来源:萌咖

Last modification:April 20th, 2021 at 10:29 am
If you think my article is useful to you, please feel free to appreciate