Skip to main content

Install Huntress Agent - Macintosh

Overview

Deploy Huntress agent on Macintosh machines

Sample Run

Play Button > Run Automation > Script
SampleRun1

Search and select Install Huntress Agent - Macintosh Image1

Click the Run button to run the script.
Run As: System
Preset Parameter: <Leave it Blank>
Image2

Run Automation: Yes
RunAutomation

Dependencies

Automation Setup/Import

Step 1

Navigate to Administration > Library > Automation
Step1

Step 2

Locate the Add button on the right-hand side of the screen, click on it and click the New Script button.
Step2

The scripting window will open.
ScriptingScreen

Step 3

Configure the Create Script section as follows:

Name: Install Huntress Agent - Macintosh
Description: Deploy Huntress agent on Macintosh machines
Categories: ProVal
Language: ShellScript
Operating System: Mac
Architecture: 64-bit
Run As: System
Image3

Step 4

Paste the following Shell script in the scripting section:

#!/bin/bash

# Huntress Installation Script for macOS via NinjaRMM
# With dynamic NinjaRMM CLI path detection

# Determine ninjarmm-cli path
if [ -f "/Applications/NinjaRMMAgent/programdata/ninjarmm-cli" ]; then
ninjarmm_cli="/Applications/NinjaRMMAgent/programdata/ninjarmm-cli"
elif [ -f "/opt/NinjaRMMAgent/programdata/ninjarmm-cli" ]; then
ninjarmm_cli="/opt/NinjaRMMAgent/programdata/ninjarmm-cli"
else
echo "ERROR: ninjarmm-cli not found on this system"
exit 1
fi

# Retrieve Huntress Account Key
accountKey="$($ninjarmm_cli get "cpvalHuntressAccountKey")"

# Validate Account Key exists
if [ -z "$accountKey" ]; then
echo "ERROR: Account Key must be stored in the organization-level custom field 'cPVAL Huntress Account Key'"
exit 1
fi

# Retrieve Organization Key with fallback
organizationKey="$($ninjarmm_cli get "cpvalHuntressOrgKey")"
[ -z "$organizationKey" ] && organizationKey="$NINJA_ORGANIZATION_NAME"

# Define script location and source URL
scriptPath="/tmp/InstallHuntress-macOS-NinjaRMM.sh"
scriptUrl="https://raw.githubusercontent.com/huntresslabs/deployment-scripts/refs/heads/main/Ninja-RMM/InstallHuntress-macOS-NinjaRMM.sh"

# Download installer script
if ! curl -s -o "$scriptPath" "$scriptUrl"; then
echo "ERROR: Failed to download Huntress installation script"
exit 1
fi

# Make executable and run
chmod +x "$scriptPath"
$scriptPath -a "$accountKey" -o "$organizationKey"

Image4

Saving the Automation

Click the Save button in the top-right corner of the screen to save your automation.
SaveButton

You will be prompted to enter your MFA code. Provide the code and press the Continue button to finalize the process.
MFA

Completed Automation

Image5

Output

  • Activity Details