I need to set a password for root on EC2 AMI Linux. I have tried with
passwd root but if I log in with
ec2-user and run
sudo su, I get a root bash without asking for a password.
sudo su asks for the user's password, the user has to be in the sudo/adm/admin/wheel group (depening on flavour of the OS) to be able to execute
The root password will be prompted when using
Check the settings in
/etc/sudoers file to see why you are not being asked for a password while using
sudo. Most likely the time-out is set to a few minutes, allowing you a passwordless sudo for e.g. 15 minutes after a successful password entry.