# Install the agent on all your servers at once

> Installing the agent one server at a time means opening each server and copying its own command.

Source: https://infranest.io/docs/install-the-agent-on-many-servers
Last updated: 2026-10-30

---

If you manage more than a handful of servers — or you spin them up from a template — this lets you install the InfraNest agent on every server with a single command, instead of copying a different one each time.

## Overview

- One enrollment key can be reused in a cloud-init file, an Ansible playbook, or a server image.
- When the install command runs on a server, that server appears in InfraNest automatically, with monitoring switched on.
- If InfraNest already recognises the server from your cloud provider, it's matched to that one instead of creating a duplicate.
- Running the command again on the same server won't add it twice.
- Each server gets its own password to report with, so switching the key off later doesn't stop servers that already installed with it.

## Create a key

1. Go to [Settings → Server agent](https://app.infranest.io/settings?tab=server-agent).
2. Select **New key**.
3. Give it a name you will recognise later, like *Production web servers*.
4. Optional: set **Expires after** if the key should stop working after a number of days, and **Maximum servers** if it should only install on so many servers.
5. Select **Create key**.
6. Copy the key, or one of the ready-made commands for **Linux**, **Windows** or **cloud-init**. The key is shown only this once.

> [!WARNING]
> The key is only shown once when you create it. Copy it or one of the ready-made commands right away — you won't be able to view it again later.

<!-- screenshot: install-the-agent-on-many-servers -->

<!-- docs-screenshots:start:install-the-agent-on-many-servers -->

![Install the agent on all your servers at once](/media/45cdc89f-e186-4469-9c7e-3767848c9379)

<!-- docs-screenshots:end:install-the-agent-on-many-servers -->

## Use it

On Linux, run the command on each server, or add it to your cloud-init file or Ansible playbook:

```sh
curl -fsSL https://get.infranest.io/agent.sh | sudo sh -s -- --enroll sek_YOUR_KEY
```

On Windows, in PowerShell as administrator:

```powershell
irm https://get.infranest.io/agent.ps1 -OutFile install.ps1
.\install.ps1 -Enroll sek_YOUR_KEY
```

Within a minute each server appears in [Monitoring → Servers](https://app.infranest.io/monitoring?view=servers) with live memory, disk and load. A server InfraNest already knew from your cloud provider stays where it was, on the **Servers** page too.

## Switch a key off

1. Go to [Settings → Server agent](https://app.infranest.io/settings?tab=server-agent).
2. Select **Revoke** next to the key.

New servers can no longer use a revoked key. Servers that already installed with it keep reporting as normal — to remove the agent from one of those, open the server and remove it there.

## Troubleshooting

If a server does not appear after running the install command, the command stops and tells you why before anything is installed:

- **The key is not valid** — it was copied incompletely. Copy it again, or create a new key.
- **The key was revoked** or **has expired** — create a new key.
- **The key has installed as many servers as it allows** — create another key, or one with a higher **Maximum servers**.
- **Your plan's limit is reached** — each new server counts towards your plan's servers and monitored servers, the same as one you add by hand.

> [!TIP]
> Every server added with a key is listed in [Settings → Audit log](https://app.infranest.io/settings?tab=audit-log), along with the key's name, so you can always trace which key brought in which server.
