linux系统一键开启root登陆

某台服务器只能key登陆,用这个后直接可以root方式登陆了:

sudo -i
echo root:要设置的密码 |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

 

THE END