GlobalProtect On-Demand Control Setup
Command-Line Control & Custom Web Browser Authentication for macOS
Tested on macOS 15 Sequoia
Compatible with Intel & Apple Silicon
Universally Adaptable
Important Note for Non-UA Users:
This script is configured by default for the University of Alaska (vpn.alaska.edu).
It works for any institution or company using GlobalProtect simply by changing the PORTAL variable on line 4 of the script to your organization's VPN portal address (e.g., vpn.yourinstitution.edu or vpn.company.com).
Why This Script Was Developed
The Problem Encountered:
When running modern versions of macOS on legacy Mac hardware using OpenCore Legacy Patcher (OCLP) or systems with non-Metal GPUs, GlobalProtect's embedded WebKit login window repeatedly crashes or fails to display properly during single sign-on (SSO/Duo) authentication. Additionally, the standard GlobalProtect app runs persistent background daemons (PanGPS and PanGPA) 24/7—consuming battery, RAM, and CPU resources even when disconnected.
The Solution:
This lightweight control script solves both issues:
- It forces GlobalProtect to route single sign-on authentication through your default system browser (e.g., Firefox or Safari), eliminating embedded GUI window crashes entirely.
- It provides complete command-line control (
start, stop, status) to run the VPN strictly on-demand, unloading all background daemons when stopped.
System & macOS Requirements
This script is compatible with both Apple Silicon (M1–M4) and Intel Macs.
| macOS Version |
Compatibility Status |
Notes |
| macOS 15 Sequoia |
Verified & Tested |
Fully tested; seamless browser handshake and daemon management. |
| macOS 10.15 (Catalina) to 14 (Sonoma) |
100% Compatible |
Standard execution across all POSIX utilities and `scutil` checks. |
| macOS 10.13 (High Sierra) to 10.14 (Mojave) |
Supported |
Requires GlobalProtect v5.1+ for system browser preference support. |
| macOS 10.12 or Older |
Not Recommended |
Legacy `launchctl` syntax changes may cause false disconnect status output. |
Installation Instructions
-
Set your default web browser:
Ensure your preferred web browser (e.g., Firefox or Safari) is selected as system default in System Settings > Desktop & Dock > Default web browser.
-
Create the script file:
Open Terminal and execute:
sudo nano /usr/local/bin/vpn.sh
-
Paste and configure the script content:
Copy the script block below into the editor.
If you are not using University of Alaska VPN, edit line 4 (PORTAL="...") to use your organization's portal address.
#!/bin/bash
# GlobalProtect On-Demand Control Script for macOS
# CHANGE THIS ADDRESS to match your organization's portal if not using University of Alaska
PORTAL="vpn.alaska.edu"
APP_BINARY="/Applications/GlobalProtect.app/Contents/MacOS/GlobalProtect"
CLI_SYMLINK="/usr/local/bin/globalprotect"
# Enforce default system browser for SAML/SSO authentication
configure_browser_pref() {
defaults write com.paloaltonetworks.GlobalProtect.settings.plist "Palo Alto Networks" -dict-add GlobalProtect "<dict><key>Settings</key><dict><key>User</key><dict><key>use-system-browser</key><string>yes</string></dict></dict></dict>" 2>/dev/null
}
# Ensure GlobalProtect CLI symlink exists
check_symlink() {
if [ ! -L "$CLI_SYMLINK" ] && [ ! -f "$CLI_SYMLINK" ]; then
if [ -f "$APP_BINARY" ]; then
sudo ln -s "$APP_BINARY" "$CLI_SYMLINK" 2>/dev/null
fi
fi
}
configure_browser_pref
check_symlink
case "$1" in
start)
echo "Starting GlobalProtect services..."
sudo launchctl load -w /Library/LaunchDaemons/com.paloaltonetworks.gp.pangps.plist 2>/dev/null
launchctl load -w /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist 2>/dev/null
echo "GlobalProtect started. Complete login in your default browser if prompted."
;;
connect)
echo "Triggering connection to $PORTAL..."
if [ -L "$CLI_SYMLINK" ]; then
"$CLI_SYMLINK" connect -portal "$PORTAL" &
else
"$APP_BINARY" connect -portal "$PORTAL" &
fi
echo "Authentication request sent. Complete login in your default browser."
;;
stop)
echo "Stopping GlobalProtect services..."
launchctl unload -w /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist 2>/dev/null
sudo launchctl unload -w /Library/LaunchDaemons/com.paloaltonetworks.gp.pangps.plist 2>/dev/null
sudo pkill -9 -f PanGPS 2>/dev/null
sudo pkill -9 -f PanGPA 2>/dev/null
sudo pkill -9 -f GlobalProtect 2>/dev/null
echo "GlobalProtect stopped."
;;
status|check)
if pgrep -f "PanGPS" > /dev/null; then
echo "GlobalProtect Service: RUNNING"
TUNNEL_ACTIVE=false
if scutil --nc list 2>/dev/null | grep -i "GlobalProtect" | grep -q "(Connected)"; then
TUNNEL_ACTIVE=true
elif ifconfig 2>/dev/null | grep -q -E "gpd|utun.*flags=.*POINTOPOINT"; then
if netstat -rn 2>/dev/null | grep -q -E "vpn|10\.|172\.|192\.168\."; then
TUNNEL_ACTIVE=true
fi
elif pgrep -f "PanGPA" > /dev/null && netstat -rn 2>/dev/null | grep -q "gpd"; then
TUNNEL_ACTIVE=true
fi
if [ "$TUNNEL_ACTIVE" = true ]; then
echo "VPN Tunnel Status: CONNECTED"
else
echo "VPN Tunnel Status: DISCONNECTED (Service active, waiting for authentication)"
fi
else
echo "GlobalProtect Service: STOPPED"
echo "VPN Tunnel Status: DISCONNECTED"
fi
;;
*)
echo "Usage: vpn.sh {start|connect|stop|status}"
exit 1
;;
esac
-
Save and exit:
Press Control + O, then Enter to save. Press Control + X to exit.
-
Make the script executable:
Grant system execution permissions:
sudo chmod +x /usr/local/bin/vpn.sh
Command Reference
| Command |
Action & Behavior |
vpn.sh start |
Loads background daemons and opens your default browser for SSO login. |
vpn.sh status |
Queries active network sockets/interfaces to show live connection state. |
vpn.sh connect |
Manually triggers a portal connection request to the configured portal. |
vpn.sh stop |
Completely unloads daemons from launchd and kills active background processes. |