Skip to content

How do I automate agent deployment across multiple organizations?

If you are an MSP with one Nanitor organization per customer, each customer has its own signup URL, and the signup URL decides which organization an agent goes into. Instead of copying each signup URL from the portal, you can get all of them with one call to the Nanitor API and store them in your RMM platform (for example NinjaOne or Datto RMM). Your RMM deployment scripts then install the agent with the right signup URL for each customer.

Before you start

  • Nanitor 6.8.0 or later. The Organizations API returns signup_url from this version.
  • curl and jq on the machine where you run the API calls.
  • An API key created in your own organization, the parent of your customer organizations. Create it under Organization management → API keys, as described in REST API. Read access is enough.
  • The key sees its own organization and that organization's direct suborganizations. Customer organizations that are not under your organization are not returned. A key with write access can also change the data of every customer organization, so use a read-only key for these steps.

Get the signup URLs

List all organizations with their signup URLs

curl -s 'https://example.nanitor.com/system_api/organizations?per_page=200' \
  -H 'Authorization: Bearer <your-api-key>' | jq '.items[] | {name, id, slug, signup_url}'

Replace example.nanitor.com with your Nanitor server's address. The API returns 20 organizations per page by default and at most 200. If you have more than 200 organizations, add &page=2, &page=3 and so on, until a page returns fewer than 200 organizations.

Example response:

{
  "name": "Contoso Ltd",
  "id": 12,
  "slug": "contoso-ltd",
  "signup_url": "https://example.nanitor.com/api/agent_get_signup_key/4e417e9b-1675-4e79-bf59-d150e57922dd/xxxxxxxx"
}
{
  "name": "Fabrikam Inc",
  "id": 13,
  "slug": "fabrikam-inc",
  "signup_url": "https://example.nanitor.com/api/agent_get_signup_key/8c2f0a61-93d4-4b7e-a0c5-2f6e1d9b7a42/xxxxxxxx"
}

Always use the signup_url exactly as the API returns it. Do not build it yourself from the slug.

Export as CSV

curl -s 'https://example.nanitor.com/system_api/organizations?per_page=200' \
  -H 'Authorization: Bearer <your-api-key>' \
  | jq -r '.items[] | [.name, .slug, .signup_url] | @csv'

Get one organization's signup URL

curl -s 'https://example.nanitor.com/system_api/organizations/<org-id>' \
  -H 'Authorization: Bearer <your-api-key>' | jq -r '.item.signup_url'

Keep the signup URLs safe

Anyone with a signup URL can connect machines to that organization, and it does not expire. Store the signup URLs and your API key in your RMM's secure fields, not in plain-text scripts that others can read.

Store the signup URLs in your RMM

  1. Match each RMM customer to its Nanitor organization by name or by slug. The slug is the URL you set when you created the organization.
  2. Store each customer's signup_url where your deployment script can read it. If your RMM supports a custom field per customer or site, create one, for example nanitor_signup_url, and fill it in for each customer.
  3. Use the stored value in your agent deployment script, as shown below.

In NinjaOne, set the signup URL as a parameter on a separate installer task for each customer instead. See Ninja RMM and Nanitor CTEM integration for MSPs.

Install the agent with the signup URL

Windows

This PowerShell command is the one the Nanitor portal shows under Agent installers. It downloads the latest agent, installs it and signs it up. Run it as administrator:

Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
$signupUrl = "<signup-url>"  # Or read it from your RMM custom field.
iex (New-Object System.Net.WebClient).DownloadString('https://nanitor.io/files/installers/install-windows.ps1')

If you have already copied the MSI to the machine, install it with the signup URL instead:

msiexec.exe /i "nanitor-agent.msi" ACCEPTEULA="yes" SIGNUP_URL="$signupUrl" /qn

For more Windows options, see How do I install/distribute the Nanitor Agent on Windows?.

Linux and macOS

The one-line installer downloads the latest agent, installs it, signs it up with the signup URL and starts it. It must run as root. If your RMM already runs scripts as root, leave out sudo.

Linux:

# $SIGNUP_URL comes from your RMM custom field.
sudo SIGNUP_URL="$SIGNUP_URL" /bin/bash -c "$(curl -fsSL https://nanitor.io/files/installers/install-linux.sh)"

macOS:

sudo SIGNUP_URL="$SIGNUP_URL" /bin/bash -c "$(curl -fsSL https://nanitor.io/files/installers/install-osx.sh)"

For other ways to install, see How do I install Nanitor Agent on Linux/BSD/Mac?.

Deploy over SSH without an RMM

If you do not use an RMM, a script can look up each signup URL when it deploys. This example installs the agent on Linux hosts over SSH. Each host must accept your SSH key, and sudo must not ask for a password, because the script cannot answer a prompt.

#!/bin/bash
# Usage: ./deploy_agents.sh <host-list-file>
# Each line of the host list file is "hostname org_id".

NANITOR_API="https://example.nanitor.com/system_api"
# Read the API key from the environment instead of writing it in the script.
API_KEY="${NANITOR_API_KEY:?Set NANITOR_API_KEY first}"

while read -r host org_id; do
    signup_url=$(curl -s "${NANITOR_API}/organizations/${org_id}" \
        -H "Authorization: Bearer ${API_KEY}" | jq -r '.item.signup_url')

    if [ -z "$signup_url" ] || [ "$signup_url" = "null" ]; then
        echo "ERROR: No signup URL for organization ${org_id}, skipping ${host}"
        continue
    fi

    echo "Deploying to ${host} (organization ${org_id})..."
    ssh -n -o BatchMode=yes "$host" "sudo SIGNUP_URL='${signup_url}' /bin/bash -c \"\$(curl -fsSL https://nanitor.io/files/installers/install-linux.sh)\""
done < "$1"

See also