Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Enable ESM configurations at scale with UA Client and Landscape

1. Overview

In this tutorial, you will learn how to use Landscape’s dashboard to enable the Ubuntu Advantage Extended Security Maintenance (ESM) entitlement on a selection of machines.

The Ubuntu Advantage client (UA Client) provides you with a simple mechanism to view, enable, and disable offerings from Canonical on your system. UA Client produces machine readable outputs and integrates with other Canonical, or third-party tooling. Beyond ESM, the UA Client can enable Ubuntu Advantage services, such as Ubuntu Security Guide (USG), FIPS, Livepatch, and more.

Landscape is Canonical’s systems management and monitoring solution. We will compose interactions with UA Client into a Landscape-aware shell script, and adjust system configurations to enable or disable ESM on your Ubuntu LTS machines.

Landscape enables you to divide your Ubuntu estate into cross sections by tags, groups, annotations, and search queries, which can also filter hardware and software metadata. These cross sections, regardless of size, can be reconfigured as easily as one machine.

2. Prerequisites

To complete this tutorial, you will need a machine running Ubuntu Pro. If you are not running Ubuntu Pro, any other supported Ubuntu LTS will work, provided it has the following:

  • An Ubuntu One account
  • An Ubuntu Advantage for Infrastructure subscription
  • UA Client attached to your Ubuntu Advantage for Infrastructure subscription
  • Landscape Client installed and registered with either Landscape on-prem or Landscape SaaS
  • Landscape Client is allowed to remotely execute scripts

Obtain an Ubuntu Advantage for Infrastructure subscription

Anyone can use Ubuntu Advantage for Infrastructure for free on up to 3 machines.

Customers with larger needs can mix and match Ubuntu Advantage Essential, Standard, and Advanced subscription types within one Ubuntu Advantage account. All Ubuntu Advantage subscriptions come with certified cryptography modules for users interested in FIPS, and Landscape on-premises.

Visit to create or sign in to your Ubuntu One account, and obtain an Ubuntu Advantage for Infrastructure subscription that matches your needs.

Attach UA Client to your Ubuntu Advantage account

Your UA token is used to connect the UA client you have installed on your machines to your Ubuntu Advantage for Infrastructure subscription.
Let’s first check whether you have already attached your UA token to the UA client by running:

$ ua status

The output will look like this:

cc-eal        no         Common Criteria EAL2 Provisioning Packages
esm-infra     yes        UA Infra: Extended Security Maintenance (ESM)
fips          yes        NIST-certified core packages
fips-updates  yes        NIST-certified core packages with priority security updates
livepatch     yes        Canonical Livepatch service
usg           yes        Security compliance and audit tools

This machine is not attached to a UA subscription.

You can see that this is not yet attached to a UA subscription. Let’s fix that now.

Your UA token can be found on your Ubuntu Advantage dashboard. To access your dashboard, you need an Ubuntu One account. If you still need to create one, ensure that you use the email address used to purchase your subscription.

The Ubuntu One account functions as a Single Sign On, so once logged in, you can type the address for the Ubuntu Advantage dashboard into the browser’s address bar: Then click on a subscription in the left hand column, and the Documentation tab on the right hand side column. Now you’re ready to attach your UA token to the UA client. Look for the copy and paste ready command to attach a machine, it will look similar to this:

$ sudo ua attach <your_ua_token>

Configure Landscape

The Landscape quickstart deployment guide offers the shortest path to a functional Landscape Server instance, and enrolling a machine to be managed by Landscape with Landscape Client. Signing up for Landscape SaaS eliminates the server installation step, and relieves you of any maintenance activities to keep Landscape up to date.

The Landscape Client steps from the quickstart deployment guide are accurate for both Landscape SaaS and Landscape on-premises users. During installation, Landscape Client will request permission for executing scripts remotely for all users.

Landscape has a feature which enables administrators to run
arbitrary scripts on machines under their control. By default this
feature is disabled in the client, disallowing any arbitrary script
execution. If enabled, the set of users that scripts may run as is
also configurable.

Enable script execution? [y/N]:

Answering yes to the Enable script execution prompt is required for this tutorial to work successfully.

By default, scripts are restricted to the 'landscape' and
'nobody' users. Please enter a comma-delimited list of users
that scripts will be restricted to. To allow scripts to be run
by any user, enter "ALL".

Script users: ALL

Answering ALL to the Script users prompt is necessary to complete this tutorial. To be maximally useful, Landscape Client should be able to execute scripts with elevated privileges (such as root) on an as-needed basis.

3. Enable ESM via Landscape

When logging into the Landscape dashboard, the secondary navigation for Scripts takes you to the central place within Landscape where shell scripts are organized. Once there, click Add Script.

Add the “ESM - Enable” script

Title: ESM - Enable


esmenable() {
  local UASTATUS
  UASTATUS=$(ua status)
  UANOTATTACHED=$(echo "$UASTATUS" | grep -c 'This machine is not attached to a UA subscription.')
  if [[ $UANOTATTACHED -eq 0 ]]; then
    ESMENTITLEMENT=$(echo "$UASTATUS" | grep -m 1 'esm-infra' | awk '{ print $2 }' | grep -c 'yes')
    if [[ $ESMENTITLEMENT -eq 1 ]]; then
      ua enable esm-infra --assume-yes
      UASTATUS=$(ua status)
      echo "'ua status' reports esm-infra is $(servicestatus 'esm-infra')"
  servicestatus 'esm-infra' > /var/lib/landscape/client/annotations.d/esm-infra
  chown landscape: /var/lib/landscape/client/annotations.d/esm-infra
  ESMENABLED=$(servicestatus 'esm-infra' | grep -c 'enabled')
  if [[ $ESMENABLED -eq 0 ]]; then
    exit 1
servicestatus() {
  echo "$UASTATUS" | grep -m 1 "$1" | awk '{ print $3 }' | sed 's/\xE2\x80\x94/unavailable/'

Run as user: root

Time limit (seconds): 300

Access group: Global access

Run the “ESM - Enable” script

  1. Within the Landscape dashboard, click Computers in the primary navigation.
  2. Select all the computers whose ESM configuration needs to be identified.
  3. Click Scripts in the secondary navigation menu
  4. Click the ESM - Enable radio button, then click Next
  5. Confirm the script reads correctly, choose when you want the script to be delivered, and click Run

Screenshot of Landscape successfully enabling ESM on a machine

4. Summary and next steps

Congratulations! Your Landscape dashboard is reporting ESM information in a searchable manner. In the search bar, try the following queries:

  • NOT annotation:esm-infra
  • annotation:esm-infra:enabled

All Ubuntu machines which are configured to have an additional 5 years of support beyond the standard support expiration, will appear for search term annotation:esm-infra:enabled. The NOT queries will reveal the inverse, and be useful in identifying machines either missing an Ubuntu Advantage subscription, or machines without ESM entitlements enabled.

Next, you can complete the tutorial which explains how to audit ESM configurations at scale with Landscape.

You can see annotations for each computer under the Info tab, right above the comments section.