1.脚本
本脚本也适用于GCP, AZURE。。。。
创建实例时,点击添加启动脚本,复制下面代码,然后等待实例开通。
#!/bin/bash echo root:Iecho |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
密码是Iecho,请及时更换密码。以上代码在 Debian/Ubuntu和CentOS 7上通过测试,其他发行版本自测.
2.修改配置文件
以当前账号登入ssh
输入sudo -i 启用root
然后
vi /etc/ssh/sshd_config
更新 文件中的 PasswordAuthentication 参数 ,
从no 改为 yes
保存,重启ssh服务。
对于 Amazon Linux、RHEL 5 和 SUSE Linux,请使用以下命令:
sudo service sshd restart
对于 Ubuntu,请使用以下命令:
sudo service ssh restart
本文参考
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-password-login/?nc1=h_ls
https://moeclub.org/2017/07/14/327/
来拔点草!