So I've got an Azure VM where I wanted to copy a file into an /etc/sudoers.d/ folder. Obviously I've tested the file before copying it, however something weird must have happened when transferring it via SSH, it might have been corrupted on the fly (should have checked with MD5 in the destination).

The consequence:

$ sudo ls /etc/sudoers.d/
>>> /etc/sudoers.d/10-backup-db-test-restore: syntax error near line 1 <<<
sudo: parse error in en_US.UTF-8 near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I've googled around and there only seems to be 2 solutions to this:

  1. Rebooting in recovery mode: something which I guess I cannot do because this server is an Azure VM.
  2. Trying pkexec, but it doesn't work! See below:

Error when launching pkexec:

$ pkexec nano /etc/sudoers.d/10-backup-db-test-restore
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/nano' as the super user
Multiple identities can be used for authentication:
 1.  Ubuntu (user1)
 2.  ,,, (user2)
Choose identity to authenticate as (1-2): 1
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie

I don't understand why pkexec doesn't work, I entered the password for user1 correctly!

Any way to reboot an Azure VM into recovery mode?

  • You can download the VHD for your VM and mount in Hyper V. That way you can access the recovery mode. Once you have fixed it, you can recreate the VM. – proteus Jul 25 '16 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.