以下是一键配置脚本,直接新建rootlogin.sh脚本文件,打开后把以下命令粘贴进去然后,运行脚本文件即可。
shell
#!/bin/bash
#set root password
sudo passwd root
#notes Document content
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin
sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password
#modify profile
sudo sed -i 's/^mesg.*/tty -s \&\& mesg n \|\| true/' /root/.profile
#install openssh
sudo apt install openssh-server
#delay
sleep 1
#modify conf
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
#restart server
sudo systemctl restart ssh
运行脚本:
shell
sh rootlogin.sh