I turned on UFW on my ubuntu linux vm in azure, and now I can't connect to it over ssh (or anything). On both the private and public IP.
Is there any way for me to connect to my vm now? e.g. the equivalent of like an iLo interface for physical machines?
Azure virtual machines (VMs) can be created through the Azure portal. The Azure portal is a browser-based user interface to create Azure resources. This quickstart shows you how to use the Azure portal to deploy a Linux virtual machine (VM) running Ubuntu 18.04 LTS.
By default, when enabled UFW will block external access to all ports on a server. In practice, that means if you are connected to a server via SSH and enable ufw before allowing access via the SSH port, you'll be disconnected.
Here is an msdn blog describing exactly this situation.
In a nutshell:
ufw_disable.sh
sh ufw_disable.sh
The script will be run as root, so there is no need to do sudo
inside the script (in fact this will cause things to fail).
ufw_disable.sh:
ufw disable
ufw status
You can add your new IP from the cloud shell.
az vm run-command invoke -g VMResourceGroup -n VM --command-id RunShellScript --scripts "ufw allow from 74.125.90.78 to anyport 22"
Change the ip address and the port to your own values.
Azure portal provides the easiest way to get into the serial console through its portal. Follow these steps
Azure Portal > Your VM > Support + Troubleshooting > Serial Console.
Now even if you firewall is blocking ssh, you can access this serial console and simply disable it using sudo ufw disable or add the 22 ssh port to the firewall
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With