在 Mac 上装过深信服 aTrust 的人,可能都遇到过同一个问题:安装很顺利,卸载却不太像一个普通 App。
直接拖进废纸篓通常没用;官方卸载器也可能被企业策略拦住。实际检查后会发现,它不只是一个应用程序,而是在系统里放了一组 LaunchDaemon、常驻进程、防火墙规则和卸载监控组件。
下面记录一次实机审计后的完整清理过程。
本文只适用于个人设备,或已经解除企业 MDM 管控的设备。如果机器仍在 MDM 管理下,aTrust 可能会在重启后被重新下发安装。
aTrust 安装了什么
aTrust 的主要残留可以分成三类:系统级服务、主程序目录和用户目录数据。
LaunchDaemon
在这台机器上可以看到 6 个系统级 LaunchDaemon:
com.sangfor.aTrustDaemon
com.sangfor.aTrustTunnel
com.sangfor.aTrustTunnelWatchDog
com.sangfor.eaio.service
com.sangfor.limit.maxfiles
com.sangfor.aTrustUninstallMonitor其中 com.sangfor.aTrustUninstallMonitor 比较关键。它会监控卸载行为,并通过 anti_uninstall.js 向企业服务端查询是否允许卸载。如果企业开启了防卸载策略,它可能会干预清理过程。
文件分布
| 路径 | 内容 |
|---|---|
/Library/sangfor/ | 主程序目录,包含 SDP 和 EAIO 模块 |
/Applications/aTrust.app | 指向主程序目录的符号链接 |
/Library/LaunchDaemons/com.sangfor.*.plist | 系统级服务配置 |
/private/etc/pf.anchors/com.sangfor.atrust | pf 防火墙锚点规则 |
/private/var/log/sangfor | 系统日志 |
/private/var/db/receipts/com.mygreatcompany.pkg.aTrust.* | pkg 安装收据 |
~/Library/Application Support/aTrust | 用户数据 |
~/Library/Application Support/aTrustTray | Tray 数据 |
~/Library/Preferences/com.electron.atrust.plist | 用户配置 |
手动卸载
清理顺序很重要:先停掉 aTrustUninstallMonitor,再停其他服务,最后删除文件。否则它可能在删除过程中重新介入。
1. 停止系统服务
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.aTrustUninstallMonitor.plist
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.aTrustTunnelWatchDog.plist
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.aTrustTunnel.plist
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.aTrustDaemon.plist
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.eaio.service.plist
sudo launchctl bootout system /Library/LaunchDaemons/com.sangfor.limit.maxfiles.plist如果某个服务已经不存在,launchctl 可能会报错,可以继续执行后面的命令。
2. 删除 LaunchDaemon 配置
sudo rm -f /Library/LaunchDaemons/com.sangfor.*.plist3. 删除主程序
sudo rm -rf /Library/sangfor
sudo rm -f /Applications/aTrust.app4. 清理系统残留
sudo rm -f /private/etc/pf.anchors/com.sangfor.atrust
sudo rm -rf /private/var/log/sangfor
sudo pkgutil --forget com.mygreatcompany.pkg.aTrust
sudo rm -f /private/var/db/receipts/com.mygreatcompany.pkg.aTrust.*5. 清理用户目录
rm -rf ~/Library/Application\ Support/aTrust
rm -rf ~/Library/Application\ Support/aTrustTray
rm -f ~/Library/Preferences/com.electron.atrust.plist一键脚本
也可以把下面脚本保存为 uninstall-atrust.sh。默认是预演模式,只打印要执行的操作;确认无误后再加 --apply 真正删除。
#!/bin/bash
# aTrust 完整卸载脚本
# 针对 /Library/sangfor/ 安装结构,基于实机审计生成
# 用法:
# 预演(不删任何东西):bash uninstall-atrust.sh
# 真正执行: sudo bash uninstall-atrust.sh --apply
set -euo pipefail
APPLY=false
[[ "${1:-}" == "--apply" ]] && APPLY=true
DRY="[DRY-RUN]"
$APPLY && DRY=""
run() {
if $APPLY; then
"$@"
else
echo " $DRY would run: $*"
fi
}
remove() {
local path="$1"
if [[ -e "$path" || -L "$path" ]]; then
echo " $DRY 删除: $path"
if $APPLY; then rm -rf "$path"; fi
fi
}
echo "=============================="
echo " aTrust 卸载脚本"
$APPLY && echo " 模式: 真实执行" || echo " 模式: 预演(加 --apply 参数才会真正删除)"
echo "=============================="
echo ""
# ── 1. 停止 LaunchDaemon 服务 ─────────────────────────────────────────────
echo "[1] 停止 LaunchDaemon 服务..."
DAEMONS=(
com.sangfor.aTrustUninstallMonitor # 先停反卸载监控
com.sangfor.aTrustTunnelWatchDog
com.sangfor.aTrustTunnel
com.sangfor.aTrustDaemon
com.sangfor.eaio.service
com.sangfor.limit.maxfiles
)
for svc in "${DAEMONS[@]}"; do
plist="/Library/LaunchDaemons/${svc}.plist"
if [[ -f "$plist" ]]; then
echo " $DRY bootout: $svc"
$APPLY && launchctl bootout system "$plist" 2>/dev/null || true
fi
done
# ── 2. 强制结束残留进程 ──────────────────────────────────────────────────
echo ""
echo "[2] 结束残留进程..."
PROCS=$(pgrep -f "sangfor|aTrust|eaio" 2>/dev/null || true)
if [[ -n "$PROCS" ]]; then
echo " $DRY kill PIDs: $(echo $PROCS | tr '\n' ' ')"
$APPLY && echo "$PROCS" | xargs kill -9 2>/dev/null || true
else
echo " 无残留进程"
fi
# ── 3. 删除 LaunchDaemon plist 文件 ──────────────────────────────────────
echo ""
echo "[3] 删除 LaunchDaemon plist..."
for svc in "${DAEMONS[@]}"; do
remove "/Library/LaunchDaemons/${svc}.plist"
done
# ── 4. 删除主程序目录 ────────────────────────────────────────────────────
echo ""
echo "[4] 删除主程序目录..."
remove "/Library/sangfor"
# ── 5. 删除 Applications 符号链接 ────────────────────────────────────────
echo ""
echo "[5] 删除 /Applications 符号链接..."
remove "/Applications/aTrust.app"
# ── 6. 清理系统级残留 ────────────────────────────────────────────────────
echo ""
echo "[6] 清理系统级残留..."
remove "/private/etc/pf.anchors/com.sangfor.atrust"
remove "/private/var/log/sangfor"
# 清除 pkg 安装收据
if $APPLY; then
pkgutil --forget com.mygreatcompany.pkg.aTrust 2>/dev/null && \
echo " pkgutil: 已清除安装收据" || true
else
echo " $DRY would run: pkgutil --forget com.mygreatcompany.pkg.aTrust"
fi
# 直接删收据文件(pkgutil --forget 可能不覆盖 bom)
remove "/private/var/db/receipts/com.mygreatcompany.pkg.aTrust.plist"
remove "/private/var/db/receipts/com.mygreatcompany.pkg.aTrust.bom"
# ── 7. 清理用户目录 ──────────────────────────────────────────────────────
echo ""
echo "[7] 清理用户数据(~/Library)..."
remove "$HOME/Library/Application Support/aTrust"
remove "$HOME/Library/Application Support/aTrustTray"
remove "$HOME/Library/Preferences/com.electron.atrust.plist"
# ── 8. 验证 ─────────────────────────────────────────────────────────────
if $APPLY; then
echo ""
echo "[8] 验证清理结果..."
REMAINING=$(find /Library/sangfor /Applications/aTrust.app \
/Library/LaunchDaemons/com.sangfor.*.plist \
"$HOME/Library/Application Support/aTrust" \
"$HOME/Library/Application Support/aTrustTray" \
2>/dev/null || true)
if [[ -z "$REMAINING" ]]; then
echo " ✓ 所有主要文件已清除"
else
echo " ⚠ 以下文件仍然存在:"
echo "$REMAINING"
fi
PROCS_LEFT=$(pgrep -f "sangfor|aTrust|eaio" 2>/dev/null || true)
if [[ -z "$PROCS_LEFT" ]]; then
echo " ✓ 无 aTrust 进程残留"
else
echo " ⚠ 仍有进程在运行:"
ps -p "$PROCS_LEFT" -o pid,user,comm 2>/dev/null || true
fi
fi
echo ""
echo "=============================="
if $APPLY; then
echo " 卸载完成。建议重启 Mac 确认彻底清除。"
else
echo " 预演完成。确认以上内容无误后,以 root 执行:"
echo " sudo bash $0 --apply"
fi
echo "=============================="使用方式:
# 预演,不删除任何文件
bash uninstall-atrust.sh
# 确认无误后执行
sudo bash uninstall-atrust.sh --apply验证
执行完成后可以检查文件和进程是否还在:
ls /Library/sangfor 2>/dev/null || echo "cleared: /Library/sangfor"
ls /Applications/aTrust.app 2>/dev/null || echo "cleared: /Applications/aTrust.app"
pgrep -fl "sangfor|aTrust|eaio" || echo "no related process"最后重启一次 Mac。如果重启后没有相关进程,也没有被重新安装,基本就清理干净了。
顺手卸载 IsompSSO
有些环境还会随 aTrust 一起安装 IsompSSO。它是用于公司内网资源免密登录的 SSO 客户端,通常没有上面这些系统级守护进程,清理起来简单很多:
sudo rm -rf /Applications/IsompSSO.app
sudo pkgutil --forget com.mygreatcompany.pkg.IsompSSO