amazon linux yum更新改变了sudo root权限

amazon linux yum更新改变了sudo root权限

我通过 ssh 进入我的服务器,运行 sudo yum update,现在系统要求我输入密码才能执行任何 sudo 操作。

回顾更新日志,我注意到这一点:/etc/sudoers.d/cloud-init 保存为 /etc/sudoers.d/cloud-init.rpmsave

可能是罪魁祸首。

无论如何,我现在不太关心到底出了什么问题,我更关心的是如何修复它,尽可能减少停机时间,因为它是一个实时网络服务器。它不是一个关键系统,所以如果它必须停机一段时间,那也没关系,但显然我更希望不要这样。

提前致谢。

答案1

我在 ec2 FAQ 上找到了一个页面,上面说要执行以下操作(http://aws.amazon.com/amazon-linux-ami/faqs/)问题其实与“问:为什么 wheel 组从 /etc/sudoers 中被禁用,如何重新启用它?”不同,但结果是一样的。

1. Stop the affected instance (do not terminate).
2. Detach the root EBS volume, using either the EC2 Console or the EC2 API tools.
3. Attach the volume to another EC2 instance to which you have remote root access.
4. Login into that instance.
5. Mount the newly attached volume.
    sudo mount /dev/xvdf /mnt
5. regain the ability to use sudo (in this case - restoring original /etc/sudoers.d/cloud-init file),  
    ec2-user ALL = NOPASSWD: ALL
    # User rules for ec2-user
    ec2-user ALL=(ALL) NOPASSWD:ALL
6. Unmount the volume.
    sudo umount -d /dev/xvdf
7. Detach the volume
8. Reattach the volume to your stopped instance (make sure that the device is the same as it was before the detachment, usually: /dev/sda1).
9. Start the affected instance

成功了。我希望有一种方法可以在不停止实例的情况下完成此操作,但没关系。我实际上无法访问这些配置文件,直到我使用上述步骤将卷附加到另一个实例以重新获得 sudo 访问权限。

相关内容