切换到 root 用户
修改root的密码
echo root:bad_password | sudo chpasswd root
使用以上命令完成 root 密码重置以后使用命令 su 登陆 root 用户, 再执行下面的命令
sshd 配置
开启 root 登录
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
开启密码验证
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
重启ssh服务
service sshd restart
一次完成
__main(){sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_configsed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_configservice sshd restart}__main
