3

I am using AWS Linux AMI2, I added ec2-user ALL=(ALL) ALL and saved the file.

Now when I run any command with sudo it displays [sudo] password for ec2-user:

How to reset this file?

2
  • 1
    Does this help, over on ServerFault - serverfault.com/q/144988/267016 Commented Jun 29, 2019 at 10:45
  • 1
    Can you boot with some other OS image and mount the drive/volume from your VM? Been a long time since I played with EC2, but Linode, DigitalOcean, etc provide for this with their vms....
    – ivanivan
    Commented Jun 29, 2019 at 15:07

2 Answers 2

0

Just remove that line.

If the problem is that you don't know the password for ec2-user, then you must find some other way to get root access.

The line ec2-user ALL=(ALL) ALL means that sudo will ask for a password, because you didn't specify NOPASSWD.

3
  • True, but the question is how do I do this, if sudo is not working? Commented Jul 8, 2019 at 8:48
  • @ctrl-alt-delor If you are locked out, you are locked out, nothing you can do. Otherwise, find a way to get access. Boot a rescue system, mount the image to another instance, or download the disk image, modify and upload.
    – RalfFriedl
    Commented Jul 11, 2019 at 17:40
  • @Yes than is the type of answer they are looking for. How to get un-locked out. Commented Jul 11, 2019 at 18:58
-3

By default, sudo requires that a user authenticate him or herself before running a command.

This behavior can be modified via the NOPASSWD tag.

For a single user, try

USERNAME ALL=(ALL:ALL) NOPASSWD:ALL

We can also modify the syntax to allow specific commands like

USERNAME ALL= NOPASSWD: /bin/kill, /bin/ls

Suoders manual has more details covering this topic

2
  • All very true, but how does this answer the question? Commented Jul 8, 2019 at 8:46
  • use the pkexec visudo to make the changes Commented Jul 8, 2019 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .