Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How can I disable the passwordless sudo access for the default ubuntu user on an EC2 instance? Is it safe to do it?

share|improve this question

2 Answers 2

Of course you can that. Is it safe? First be sure to set password on user ubuntu.

Edit the sudoers file with command visudo otherwise be very careful. Find the line matching ubuntu user and change it to ubuntu ALL=(ALL:ALL) ALL

  • username is in the beggining of the line
  • first ALL indicates to which hosts it applies (in that case all of them)
  • second ALL is for which user ubuntu can run commands (in that case all of them)
  • third ALL is for which groups ubuntu can run commands (in that case all of them)
  • last but not least ALL means which commands can you run (in that case all of them)

Be sure to chek the manual of sudoers man sudoers. For the first try you can create another user and add it to suders.

share|improve this answer

Yes, but make sure to set that user's password to something known before you do that.

share|improve this answer
Ok. But how do I do it? What do I need to put into the sudoers file? –  Shoan Jul 24 '14 at 16:27
@Shoan You just remove NOPASSWD: –  Michael Hampton Jul 27 '14 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.