Featured image of post AWS的Lightsail开启Root登录的脚本

AWS的Lightsail开启Root登录的脚本

   
文章摘要
小tips……😋

直接复制执行

#!/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

更详细的步骤:

获取权限

sudo -i

然后编辑

nano /etc/ssh/sshd_config

查找 PermitRootLogin prohibit-password (可能在注释里面)改成 PermitRootLogin yes

查找 PasswordAuthentication no 改成 PasswordAuthentication yes

CTRL + O 然后 ENTER 保存

nano /etc/ssh/sshd_config.d/*

修改或者添加 PasswordAuthentication no 改成 PasswordAuthentication yes

service sshd restart

添加密码

passwd

添加密码之后,删除key(注意备份),reboot之后使用root和密码登录

CC BY-NC-SA 4.0 创意的非商业派对入场券
最后更新于 2025-01-07 15:17
晚来天欲雪,能饮一杯无