Group management is necessary to have governance and compliance in check. The main idea of any governance talk is to have Azure Policies and A
Did this problem ever happen to you? If yes, then you know that the way to solving this issue is by booting the distro into the Single User mode. But how do you do that in Azure? Well Serial Console to the rescue!
Usually this is easily solvable using the Run Command or by using the Reset Password blade but in this case imagine that they don’t work. This is the case of the SAP deployment using the RHEL VMs. You cannot do anything if you’ve lost access and if the VM crashes it’s even worse.
You need to get to grub so you can boot the VM in single user mode. The problem here is that the VM is very fast for the serial console to connect and press the ESC button in the magic moment.
So what can you do?
The solution to that problem is to stop the VM without de-allocating it. This means that the VM on the Hyper-V server in the backend is not deleted but preserved. This means that you can have the serial console in standby to have a chance at that magic moment. How do you know that? Check figs 1 and 2.
#stop the VM without de-allocation.
Stop-AzureRMVM -Name $VMNAME -ResourceGroup $RESOURCEGROUP -StayProvisioned -Verbose
Once you’ve gotten to the screens that the VM is starting, this is what you need to watch for and then mash the ESC button:
Once you’ve managed to enter GRUB, you’re home free to reset the password using the steps below Press e in the Serial Console to edit the first OS line.
- Go to the kernel line which starts with linux16
- Add rd.break to the end of the line which will break the boot cycle. If
selinuxis enabled then add rd.break enforcing=0
- Exit GRUB and reboot with the rd.break command saved by pressing ctrl x
- During this reboot, the VM will go into the Emergency Mode where you have to mount the
systemrootusing the “mount -o remount, rw/ sysroot” command.
- This will boot you in single user mode, where you will have to type in chroot /
sysrootto switch into the sysrootjail and then reset the password for the root user with passwd
- Edit the sshd_config file “nano /etc/ssh/sshd_config” using your preferred editor so you enable root access using the Serial Console by setting PermitRootLogin yes
- Once you’re done, reboot the VM and you’ve gotten root access.
After you’re done resetting all the passwords, installing all the agents so you’re not confronted with this again, set PermitRootLogin no and you’re golden ?
Have a good one!