[LINUX] EC2 now gives sudo runtime error sudo: / usr / bin / sudo be owned by uid 0 and the setuid bit set

Introduction

I accidentally changed the permissions under / bin and got an error when executing the sudo command. (Sure) I can no longer log in as the root user.

Conclusion

https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-sudo-commands/ With reference to the above, if you set the script in the instance settings of the AWS EC2 console, it will be restored as root: root.

Details

When I typed a command in the flow, I intended `chown -R hoge bin / ``` but specified `/ bin``` ...

There is a way to make up for typos such as spelling mistakes in commands, but since they are correct, this case cannot be prevented. You can narrow down the privileges, such as not giving sudo privileges to users who make such mistakes, but I was the server administrator.

It will be a "careful" level measure, but I would like to be aware of the following

--Do not specify the absolute path when executing the command to make changes --Be sure to review before executing the command

in conclusion

Thanks to the people in AWS for preparing the recovery method: sob:

Recommended Posts

EC2 now gives sudo runtime error sudo: / usr / bin / sudo be owned by uid 0 and the setuid bit set