原文鏈接:http://chenxuhua.com/blog/aws-lightsail-enable-root-login/
將下面代碼中的第一句中的 Passwd
改為自己將要設置的密碼,否則默認 root
密碼為 Passwd
。
#!/bin/bash
echo root:Passwd |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