Although there are many answers to this problem, the scenario is different here:
I’m using Ubuntu 18.04 on Azure.
By mistake, I made sudoers
file world-writable (sudo chmod o+w /etc/sudoers
). There is an appropriate way to fix.
For this, I need an Ubuntu user’s password
output:-
ubuntu@azurevm:~$ ls -la /etc/sudoers
-r--r---w- 1 root root 755 Jan 18 2018 /etc/sudoers
ubuntu@azurevm:~$
ubuntu@azurevm-VM:~$
ubuntu@azurevm:~$
ubuntu@azurevm:~$ pkexec chmod 0755 /etc/sudoers
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/chmod' as the super user
Authenticating as: Ubuntu (ubuntu)
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
This incident has been reported.
ubuntu@azurevm:~$ uname -a
Linux azurevm 4.18.0-1018-azure #18~18.04.1-Ubuntu SMP Tue May 7 18:09:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
whereas the authentication mode chosen while deploying VM was SSH-based. There are other ways to fix. Neither I couldn't reset the password for ubuntu nor the azure CLI is accessible.
Let me know how I can fix this or if you need further information on this.
Sorry but that is not a mistake but a deliberate action. At my office you would get fired for doing something like that ...
On cloud instances you can not use a live session, grub rescue, nor use the system itself to fix this.
There is only 1 method when using cloud instances and it should be well explained on the usage pages for Azure: create a new instance, mount your disk into this instance as a 2nd disk and then chmod the file back to the correct permissions. And then reconnect the disk to the old instance.
This method should be 2nd nature when using cloud services. As well as making snapshots and restoring snapshots.
Ubuntu User password reset option is given by Azure. Use below process.
Login into the portal.azure.com >> Open VM >> go to the section Support + troubleshooting >> Select Reset password >> there are 3 setting available :
1. Reset password 2. Reset SSH public key 3. Reset configuration only
Select reset password.
if you are still facing the issue for login then follow the below process.
Login into the portal.azure.com >> Open VM >> go to the section Support + troubleshooting >> Open Serial console >> restart the server it will show you the grub menu
Below document will help you about Azure Ubuntu single user mode.
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/serial-console-grub-single-user-mode