Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall fleetd remotely #27024

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft

Uninstall fleetd remotely #27024

wants to merge 32 commits into from

Conversation

noahtalerman
Copy link
Member

@noahtalerman noahtalerman commented Mar 11, 2025

For the following dogfood issue: fleetdm/confidential#9685

  • Update guide to cater towards IT admins that only have remote access (not physical) to the computer
  • Add a new uninstall fleetd script for macOS to dogfood. Link to this script from the guide
  • Move uninstall fleetd (aka cleanup) scripts for Windows and Linux from orbit/ to it-and-security (dogfood) because we're not using these anywhere else in the code

- Update guide to cater towards IT admins that have remote access (not physical)
@noahtalerman noahtalerman marked this pull request as ready for review March 12, 2025 17:11
@noahtalerman noahtalerman requested a review from a team as a code owner March 12, 2025 17:11
@noahtalerman noahtalerman requested review from allenhouchins and removed request for Drew-P-drawers March 12, 2025 17:12
Comment on lines 1 to 3
# Please don't delete. This script is referenced in the guide here: https://fleetdm.com/guides/how-to-uninstall-fleetd

#!/bin/sh
Copy link
Member Author

@noahtalerman noahtalerman Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allenhouchins do you know what happens if I add a comment like this before the shebang? Will this "just work"?

@noahtalerman noahtalerman removed the request for review from Drew-P-drawers March 12, 2025 18:44
@noahtalerman
Copy link
Member Author

noahtalerman commented Mar 12, 2025

Hmm, it looks like the linux-uninstall-fleetd.sh script won't uninstall all of fleetd (Fleet Desktop, Orbit, and osquery). It looks like it just stops Orbit.

@allenhouchins when you get the chance, can you please run the script on an enrolled Linux host to help me check?

#!/bin/bash

# Please don't delete. This script is referenced in the guide here: https://fleetdm.com/guides/how-to-uninstall-fleetd

sudo systemctl stop orbit.service
sudo systemctl disable orbit.service
sudo rm -rf /var/lib/orbit /opt/orbit /var/log/orbit /usr/local/bin/orbit /etc/default/orbit /usr/lib/systemd/system/orbit.service /opt/orbit

@lucasmrod
Copy link
Member

lucasmrod commented Mar 12, 2025

Hmm, it looks like the linux-uninstall-fleetd.sh script won't uninstall all of fleetd (Fleet Desktop, Orbit, and osquery). It looks like it just stops Orbit.

@allenhouchins when you get the chance, can you please run the script on an enrolled Linux host to help me check?

#!/bin/bash

# Please don't delete. This script is referenced in the guide here: https://fleetdm.com/guides/how-to-uninstall-fleetd

sudo systemctl stop orbit.service
sudo systemctl disable orbit.service
sudo rm -rf /var/lib/orbit /opt/orbit /var/log/orbit /usr/local/bin/orbit /etc/default/orbit /usr/lib/systemd/system/orbit.service /opt/orbit

AFAICS, similarly to the macOS script, the script has to run asynchronously otherwise the script itself may be killed at the first sudo systemctl stop orbit.service.

@noahtalerman
Copy link
Member Author

AFAICS, similarly to the macOS script, the script has to run asynchronously otherwise the script itself may be killed at the first sudo systemctl stop orbit.service.

@lucasmrod dang. Does this mean we can't run these macOS & Linux scripts from Fleet to remove fleetd from hosts?

@lucasmrod
Copy link
Member

lucasmrod commented Mar 13, 2025

AFAICS, similarly to the macOS script, the script has to run asynchronously otherwise the script itself may be killed at the first sudo systemctl stop orbit.service.

@lucasmrod dang. Does this mean we can't run these macOS & Linux scripts from Fleet to remove fleetd from hosts?

Scripts it-and-security/lib/macos/scripts/macos-uninstall-fleetd.sh and it-and-security/lib/windows/scripts/windows-uninstall-fleetd.ps1 seem that already support the "asynchronous" mode to be able to run the script from Fleet.
The one for Linux needs to be updated to do a similar approach.

PS: Also there's some duplication of scripts in orbit/tools/cleanup, scripts/mdm/ and it-and-security/lib/{windows|linux}/scripts. If possible, we should have one version that we can continue to iterate and improve.

PSS: For Windows it seems we have two scripts, one for removing fleetd (scripts/mdm/windows/windows-remove-fleetd.ps1) and one for unenrolling the device from the MDM server (scripts/mdm/windows/windows-unenroll-mdm.ps1), maybe it should all be put in the remove one?.

@noahtalerman
Copy link
Member Author

The one for Linux needs to be updated to do a similar approach.

Ah, got it. Marking this PR as draft until we figure this out.

PS: Also there's some duplication of scripts in orbit/tools/cleanup, scripts/mdm/ and it-and-security/lib/{windows|linux}/scripts.

I saw that! But chose to wait to deduplicate to change less now. But now I'm thinking you, Lucas, and I can hop on a call to figure that out. I scheduled some time for us next week.

PSS: For Windows it seems we have two scripts, one for removing fleetd (scripts/mdm/windows/windows-remove-fleetd.ps1) and one for unenrolling the device from the MDM server (scripts/mdm/windows/windows-unenroll-mdm.ps1), maybe it should all be put in the remove one?.

I think we can come back to this. That said, I also think we can move these to it-and-security/ so they get touched more during dogfooding and, thus, we can improve them faster.

@noahtalerman noahtalerman marked this pull request as draft March 13, 2025 13:07
@lucasmrod lucasmrod self-assigned this Mar 13, 2025
@allenhouchins
Copy link
Member

@noahtalerman there are quite a few changes I'll want to make before putting these in our it-and-security folder. For example, the macOS one is referencing GITHUB_ACTIONS, the script names don't follow our naming convention, they have passwords as strings instead of secrets, etc. Can this hang out as a draft for a few days until I can address those changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants