Search code examples
azureufw

Enabled UFW, now can't connect to my ubuntu azure vm


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?


Solution

  • Here is an msdn blog describing exactly this situation.

    In a nutshell:

    1. Logon to the Azure portal
    2. VM Name > Extensions > Add > Select “Custom Script for Linux” > Create
    3. Upload the bash script I've appended below. Call it ufw_disable.sh
    4. Set the command as sh ufw_disable.sh
    5. Click OK, and wait for the script to deploy and execute.

    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