2

I have a Linux server on Microsoft Azure. It's an Ubuntu 14 Server. Apparently, I've done something wrong with the UFW (firewall) configuration and now I can't ssh into machine at all. I need to disable the firewall to get back into machine. I assume the only option I have now is to try to do it via PowerShell since Azure doesn't provide any KVM access.

Is this possible? How can I execute a shell command via PowerShell?

3

There is no way to run commands on an Azure VM from outside the VM itself; there also is no VM console access. This is a really big limit in Azure, unfortunately.

If you accidentally lock yourself out of a VM, the only way to recover it is by downloading its virtual disk and running it on a local Hyper-V server, where you can get console access and fix whatever is wrong; or, if the problem can be fixed offline (f.e. by editing a configuration file), you can attach the disk to another Azure VM and work on it from there.

| improve this answer | |
  • This isn't completely accurate. You can Delete the VM in question, while preserving the vhd, and attach the vhd to a healthy, running Linux VM, to get access to the disk. – David Makogon Aug 19 '15 at 12:50
  • That's the second option I mentioned ("you can attach the disk to another Azure VM and work on it from there"). – Massimo Aug 19 '15 at 12:53
  • Ah. Reading comprehension issues this morning... – David Makogon Aug 19 '15 at 12:55
2

If you have installed the custom script extension, you may use it to disable or configure your firewall.

| improve this answer | |
1

EDIT @massimo already answered this (and I didn't realize he covered the attach-disk solution). But, since I already typed this up, I'll leave the answer here, since it contains a bit more detail about attaching a disk from a locked-out VM...


To access your VM's disk if you're locked out, you can delete the Virtual Machine (but not delete the disk/vhd or any attached disks), which breaks the lease on the page blob holding the vhd. Then, you should be able to attach the vhd to a running Linux VM as an attached disk. At this point, you should be able to access the files on the disk.

I don't know anything about the firewall config and if you'll be able to alter it this way, but at least you'll have file-level access.

| improve this answer | |
1

Azure provides an extension to recover access to Linux VMs in many scenarios. Jointly with custom script, as @proteus mentioned, you should be able to fix this without recreating the VM.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.