On Ubuntu, cloud-init can use instance metadata to set up networking, user accounts, and SSH access. Once provisioning is complete, you can disable cloud-init to manage those settings locally on later boots.

An empty marker file tells Ubuntu to skip cloud-init at boot. The package stays installed, and existing accounts, SSH keys, and saved network configuration stay in place.

Some providers use cloud-init after the first boot to apply changes such as new SSH keys or additional network interfaces. Disable it only once you can manage the instance without those provider updates.

Steps to disable cloud-init on Ubuntu:

Start in an SSH session to a provisioned Ubuntu instance with cloud-init enabled at boot and cloud-init.target active. Your cloud-init version must include the boot_status_code field in the output of cloud-init status --format json. Use an account that can run sudo. Before changing the server, make sure you can sign in to the provider's console or serial console with a password-based Ubuntu account that can run sudo, independently of SSH.

  1. Confirm that cloud-init has finished provisioning the instance.
    $ cloud-init status --wait --long

    The command waits for cloud-init to finish. Continue only if the output reports extended_status: done.

  2. Check that the cloud-init target was enabled for this boot.
    $ systemctl is-enabled cloud-init.target
    enabled-runtime

    The cloud-init generator enables the target at boot. Stop if the command returns anything other than enabled-runtime.

  3. Check that the cloud-init target is active before changing the server.
    $ systemctl is-active cloud-init.target
    active

    Stop if the target is in any other state.

  4. Disable cloud-init on future boots by creating the empty marker file /etc/cloud/cloud-init.disabled.

    The next boot skips cloud-init, including any updates your provider sends through it. If SSH is unavailable after the reboot, sign in at the console, remove the marker with sudo rm /etc/cloud/cloud-init.disabled, and reboot with sudo reboot to let cloud-init run again.

    $ sudo touch /etc/cloud/cloud-init.disabled
  5. Check that the cloud-init target is still active with the marker in place.
    $ systemctl is-active cloud-init.target
    active

    The marker takes effect at the next boot.

  6. Reboot the server to apply the change.

    The reboot closes your current SSH session.

    $ sudo reboot
  7. Reconnect to the server over SSH with the same account.

    A fresh login after the server comes back confirms that you still have network access to the instance through that account.

  8. Check that cloud-init recognizes the disable marker after the reboot.
    $ cloud-init status --long
    status: disabled
    extended_status: disabled
    boot_status_code: disabled-by-marker-file
    ##### snipped #####

    The disabled-by-marker-file code reports that the marker exists. The target's state in the next step shows whether the new boot skipped cloud-init.

  9. Verify that the cloud-init target is inactive after the reboot.
    $ systemctl is-active cloud-init.target
    inactive

    The target was active before the reboot. Its inactive state on the new boot confirms that Ubuntu booted without reaching the cloud-init target.

Share this guide