Skip to content

Commit

Permalink
Document ways to provide multiple Agent uninstall tokens (#6300)
Browse files Browse the repository at this point in the history
* Document ways to provide multiple Agent uninstall tokens

* Apply suggestions from code review

Co-authored-by: Benjamin Ironside Goldstein <91905639+benironside@users.noreply.github.com>

---------

Co-authored-by: Benjamin Ironside Goldstein <91905639+benironside@users.noreply.github.com>
(cherry picked from commit 87e3acb)

# Conflicts:
#	docs/getting-started/uninstall-agent.asciidoc
#	docs/serverless/edr-install-config/agent-tamper-protection.asciidoc
#	docs/serverless/edr-install-config/uninstall-agent.asciidoc
  • Loading branch information
natasha-moore-elastic authored and mergify[bot] committed Dec 17, 2024
1 parent 139d60c commit 034d337
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/getting-started/agent-tamper-protection.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ If you need the uninstall token to remove {agent} from an endpoint, you can find

** Click the *Show token* icon in the *Token* column to reveal a specific token.
** Click the *View uninstall command* icon in the *Actions* column to open the *Uninstall agent* flyout, containing the full uninstall command with the token.

TIP: If you have many tamper-protected {agent} policies, you may want to <<multiple-uninstall-tokens>> in a single command.
73 changes: 73 additions & 0 deletions docs/getting-started/uninstall-agent.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,84 @@

To uninstall {agent} from a host, run the `uninstall` command from the directory where it's running. Refer to the {fleet-guide}/uninstall-elastic-agent.html[{fleet} and {agent} documentation] for more information.

<<<<<<< HEAD
If <<agent-tamper-protection,Agent tamper protection>> is enabled on the Agent policy for the host, you'll need to include the uninstall token in the command, using the `--uninstall-token` flag. You can <<fleet-uninstall-tokens,find the uninstall token>> on the Agent policy or at *{fleet}* -> *Uninstall tokens*.
=======
If <<agent-tamper-protection,Agent tamper protection>> is enabled on the Agent policy for the host, you'll need to include the uninstall token in the command, using the `--uninstall-token` flag. You can <<fleet-uninstall-tokens,find the uninstall token>> on the Agent policy. Alternatively, find *{fleet}* in the navigation menu or by using the {kibana-ref}/introduction.html#kibana-navigation-search[global search field], and select *Uninstall tokens*.
>>>>>>> 87e3acb9 (Document ways to provide multiple Agent uninstall tokens (#6300))
For example, to uninstall {agent} on a macOS or Linux host:
[source,shell]
----------------------------------
sudo elastic-agent uninstall --uninstall-token 12345678901234567890123456789012
----------------------------------
<<<<<<< HEAD
=======

[discrete]
[[multiple-uninstall-tokens]]
== Provide multiple uninstall tokens

If you have multiple tamper-protected {agent} policies, you may want to provide multiple uninstall tokens in a single command. There are two ways to do this:

* The `--uninstall-token` command can receive multiple uninstall tokens separated by a comma, without spaces.
+
[source,shell]
----------------------------------
sudo elastic-agent uninstall -f --uninstall-token 7b3d364db8e0deb1cda696ae85e42644,a7336b71e243e7c92d9504b04a774266
----------------------------------

* `--uninstall-token`'s argument can also be a path to a text file with one uninstall token per line.
+
NOTE: You must use the full file path, otherwise the file may not be found.
+
[source,shell]
----------------------------------
sudo elastic-agent uninstall -f --uninstall-token /tmp/tokens.txt
----------------------------------
+
In this example, `tokens.txt` would contain:
+
[source,txt]
----------------------------------
7b3d364db8e0deb1cda696ae85e42644
a7336b71e243e7c92d9504b04a774266
----------------------------------

[discrete]
[[uninstall-endpoint]]
== Uninstall {elastic-endpoint}

Use these commands to uninstall {elastic-endpoint} from a host **ONLY** if {fleet-guide}/uninstall-elastic-agent.html[uninstalling an {agent}] is unsuccessful.

Windows

[source,shell]
----------------------------------
cd %TEMP%
copy "c:\Program Files\Elastic\Endpoint\elastic-endpoint.exe" elastic-endpoint.exe
.\elastic-endpoint.exe uninstall
del .\elastic-endpoint.exe
----------------------------------

macOS

[source,shell]
----------------------------------
cd /tmp
cp /Library/Elastic/Endpoint/elastic-endpoint elastic-endpoint
sudo ./elastic-endpoint uninstall
rm elastic-endpoint
----------------------------------

Linux

[source,shell]
----------------------------------
cd /tmp
cp /opt/Elastic/Endpoint/elastic-endpoint elastic-endpoint
sudo ./elastic-endpoint uninstall
rm elastic-endpoint
----------------------------------
>>>>>>> 87e3acb9 (Document ways to provide multiple Agent uninstall tokens (#6300))
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[[security-agent-tamper-protection]]
= Prevent {agent} uninstallation

// :description: Block unauthorized attempts to uninstall {agent} on hosts.
// :keywords: serverless, security, how-to


For hosts enrolled in {elastic-defend}, you can prevent unauthorized attempts to uninstall {agent} and {elastic-endpoint} by enabling **Agent tamper protection** on the Agent policy. This offers an additional layer of security by preventing users from bypassing or disabling {elastic-defend}'s endpoint protections.

When enabled, {agent} and {elastic-endpoint} can only be uninstalled on the host by including an uninstall token in the uninstall CLI command. One unique uninstall token is generated per Agent policy, and you can retrieve uninstall tokens in an Agent policy's settings or in the {fleet} UI.

.Requirements
[NOTE]
====
* Agent tamper protection requires the Endpoint Protection Complete <<elasticsearch-manage-project,project feature>>.
* Hosts must be enrolled in the {elastic-defend} integration.
* {agent}s must be version 8.11.0 or later.
* This feature is supported for all operating systems.
====

[role="screenshot"]
image::images/agent-tamper-protection/agent-tamper-protection.png[Agent tamper protection setting highlighted on Agent policy settings page]

[discrete]
[[enable-agent-tamper-protection]]
== Enable Agent tamper protection

You can enable Agent tamper protection by configuring the {agent} policy.

. Go to **{fleet}** -> **Agent policies**, then select the Agent policy you want to configure.
. Select the **Settings** tab on the policy details page.
. In the **Agent tamper protection** section, turn on the **Prevent agent tampering** setting.
+
This makes the **Get uninstall command** link available, which you can follow to get the uninstall token and CLI command if you need to <<security-uninstall-agent,uninstall an Agent>> on this policy.
+
[TIP]
====
You can also access an Agent policy's uninstall tokens on the **Uninstall tokens** tab on the **{fleet}** page. Refer to <<fleet-uninstall-tokens,Access uninstall tokens>> for more information.
====
. Select **Save changes**.

[discrete]
[[fleet-uninstall-tokens]]
== Access uninstall tokens

If you need the uninstall token to remove {agent} from an endpoint, you can find it in several ways:

* **On the Agent policy** — Go to the Agent policy's **Settings** tab, then click the **Get uninstall command** link. The **Uninstall agent** flyout opens, containing the full uninstall command with the token.
* **On the {fleet} page** — Go to **{fleet}** -> **Uninstall tokens** for a list of the uninstall tokens generated for your Agent policies. You can:
+
** Click the **Show token** icon in the **Token** column to reveal a specific token.
** Click the **View uninstall command** icon in the **Actions** column to open the **Uninstall agent** flyout, containing the full uninstall command with the token.

TIP: If you have many tamper-protected {agent} policies, you may want to <<multiple-uninstall-tokens>> in a single command.
143 changes: 143 additions & 0 deletions docs/serverless/edr-install-config/uninstall-agent.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
[[security-uninstall-agent]]
= Uninstall {agent}

// :description: Remove {agent} from a host.
// :keywords: serverless, security, how-to


To uninstall {agent} from a host, run the `uninstall` command from the directory where it's running. Refer to the {fleet-guide}/uninstall-elastic-agent.html[{fleet} and {agent} documentation] for more information.

If <<security-agent-tamper-protection,Agent tamper protection>> is enabled on the Agent policy for the host, you'll need to include the uninstall token in the command, using the `--uninstall-token` flag. You can <<fleet-uninstall-tokens,find the uninstall token>> on the Agent policy or at **{fleet}** -> **Uninstall tokens**.

For example:

++++
<div class="tabs" data-tab-group="edr-install-config-uninstall-agent">
<div role="tablist" aria-label="edr-install-config-uninstall-agent">
<button role="tab" aria-selected="true" aria-controls="edr-install-config-uninstall-agent-macos-panel" id="edr-install-config-uninstall-agent-macos-button">
macOS
</button>
<button role="tab" aria-selected="false" aria-controls="edr-install-config-uninstall-agent-linux-panel" id="edr-install-config-uninstall-agent-linux-button">
Linux
</button>
<button role="tab" aria-selected="false" aria-controls="edr-install-config-uninstall-agent-windows-panel" id="edr-install-config-uninstall-agent-windows-button" tabindex="-1">
Windows
</button>
</div>
<div tabindex="0" role="tabpanel" id="edr-install-config-uninstall-agent-macos-panel" aria-labelledby="edr-install-config-uninstall-agent-macos-button">
++++
[source,shell]
----
sudo elastic-agent uninstall --uninstall-token 12345678901234567890123456789012
----

++++
</div>
<div tabindex="0" role="tabpanel" id="edr-install-config-uninstall-agent-linux-panel" aria-labelledby="edr-install-config-uninstall-agent-linux-button" hidden="">
++++
[source,shell]
----
sudo elastic-agent uninstall --uninstall-token 12345678901234567890123456789012
----

++++
</div>
<div tabindex="0" role="tabpanel" id="edr-install-config-uninstall-agent-windows-panel" aria-labelledby="edr-install-config-uninstall-agent-windows-button" hidden="">
++++
[source,shell]
----
C:\"Program Files"\Elastic\Agent\elastic-agent.exe uninstall --uninstall-token 12345678901234567890123456789012
----

++++
</div>
</div>
++++

[discrete]
[[multiple-uninstall-tokens]]
== Provide multiple uninstall tokens

If you have multiple tamper-protected {agent} policies, you may want to provide multiple uninstall tokens in a single command. There are two ways to do this:

* The `--uninstall-token` command can receive multiple uninstall tokens separated by a comma, without spaces.
+
[source,shell]
----------------------------------
sudo elastic-agent uninstall -f --uninstall-token 7b3d364db8e0deb1cda696ae85e42644,a7336b71e243e7c92d9504b04a774266
----------------------------------

* `--uninstall-token`'s argument can also be a path to a text file with one uninstall token per line.
+
NOTE: You must use the full file path, otherwise the file may not be found.
+
[source,shell]
----------------------------------
sudo elastic-agent uninstall -f --uninstall-token /tmp/tokens.txt
----------------------------------
+
In this example, `tokens.txt` would contain:
+
[source,txt]
----------------------------------
7b3d364db8e0deb1cda696ae85e42644
a7336b71e243e7c92d9504b04a774266
----------------------------------

[discrete]
[[uninstall-endpoint]]
== Uninstall {elastic-endpoint}

Use these commands to uninstall {elastic-endpoint} from a host **ONLY** if {fleet-guide}/uninstall-elastic-agent.html[uninstalling an {agent}] is unsuccessful.

++++
<div class="tabs" data-tab-group="edr-install-config-uninstall-agent">
<div role="tablist" aria-label="edr-install-config-uninstall-agent">
<button role="tab" aria-selected="true" aria-controls="edr-uninstall-config-uninstall-agent-macos-panel" id="edr-install-config-uninstall-agent-macos-button">
macOS
</button>
<button role="tab" aria-selected="false" aria-controls="edr-uninstall-config-uninstall-agent-linux-panel" id="edr-install-config-uninstall-agent-linux-button" tabindex="-1">
Linux
</button>
<button role="tab" aria-selected="false" aria-controls="edr-uninstall-config-uninstall-agent-windows-panel" id="edr-install-config-uninstall-agent-windows-button" tabindex="-1">
Windows
</button>
</div>
<div tabindex="0" role="tabpanel" id="edr-uninstall-config-uninstall-agent-macos-panel" aria-labelledby="edr-install-config-uninstall-agent-macos-button">
++++
[source,shell]
----
cd /tmp
cp /Library/Elastic/Endpoint/elastic-endpoint elastic-endpoint
sudo ./elastic-endpoint uninstall
rm elastic-endpoint
----

++++
</div>
<div tabindex="0" role="tabpanel" id="edr-uninstall-config-uninstall-agent-linux-panel" aria-labelledby="edr-install-config-uninstall-agent-linux-button" hidden="">
++++
[source,shell]
----
cd /tmp
cp /opt/Elastic/Endpoint/elastic-endpoint elastic-endpoint
sudo ./elastic-endpoint uninstall
rm elastic-endpoint
----

++++
</div>
<div tabindex="0" role="tabpanel" id="edr-uninstall-config-uninstall-agent-windows-panel" aria-labelledby="edr-install-config-uninstall-agent-windows-button" hidden="">
++++
[source,shell]
----
cd %TEMP%
copy "c:\Program Files\Elastic\Endpoint\elastic-endpoint.exe" elastic-endpoint.exe
.\elastic-endpoint.exe uninstall
del .\elastic-endpoint.exe
----

++++
</div>
</div>
++++

0 comments on commit 034d337

Please sign in to comment.