We help IT Professionals succeed at work.

How do I get ssh access back to my linux vm if I'm locked out due to selinux policies?

neal wang
neal wang asked
on
Medium Priority
69 Views
Last Modified: 2020-02-05
How do I get ssh access back to my centos linux vm if I'm locked out due to selinux policies?

My coworker turned on some selinux policies and now we can't ssh back into the linux vm which is hosted on azure cloud.

This is a centos vm hosted on Azure cloud. I'm not able to ssh into the machine anymore. How do I get inside the machine to disable the policy?
Comment
Watch Question

Dr. KlahnPrincipal Software Engineer
CERTIFIED EXPERT

Commented:
So far as I can see, you cannot telnet in and cannot SSH in, and obviously you can't boot to single-user mode, so ... you're pretty much out of luck.  Only root can undo those changes, and root must have a way to get in.

If this were a local, physical machine then there would be the great advantage that you could go to the console and log in as root on the physical console port.  However, unless the hosting vendor has provided you a way to use the console port without using SSH or telnet, you will probably have to restore from the most recent backup made before the configuration problem occurred.
AlanConsultant
CERTIFIED EXPERT

Commented:
Can you roll back the changes (restore to prior to the changes)?

Alan.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
See whether you have console like access to the VM

Not sure there is any Selinux policy one could implement that had such an impact, sure it was not a firewall change?
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Best option is to boot into single user mode + reverse out changes made.

So first you'll open a ticket with Azure to determine if it's possible to do this related to your specific account setup.

After Azure answers, update this question with their answer.

Their answer will determine next steps.
This was Azure's support team answer:
My coworker spent time with them to do this:

https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshoot-recovery-disks-portal-linux