rootgoogle-compute-enginesudoers

sudoers - Google Compute Engine - no access to root


I have a Google Compute Engine VM instance with a Asterisk Server running on it. I get this message when I try to run sudo:

sudo: parse error in /etc/sudoers near line 21
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Is there a password for root so I can try to change it there? Any suggestions on this?


Solution

  • It looks like you have manually edited the /etc/sudoers file so while you would normally have sudo access, due to the parse error, you won't be able to do this directly.

    Here's how to fix this situation.

    1. Save the current boot disk

    2. Fix the /etc/sudoers on the boot disk

    3. Restore the original VM instance

    How to avoid this in the future

    Always use the command visudo rather just any text editor directly to edit the /etc/sudoers file which will validate the contents of the file prior to saving it.