Skip to content

autossh 与 LaunchAgent 概览

autossh 适合在本机维持长期 SOCKS 代理。macOS 上可通过 LaunchAgent 管理用户态自启动,但文件存在不等于服务已注册或正在运行。

关键判断:

bash
launchctl list | grep com.example.autossh
launchctl print gui/$(id -u)/com.example.autossh

典型部署顺序:

bash
brew install autossh
cp com.example.autossh.plist ~/Library/LaunchAgents/
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.autossh.plist
launchctl enable gui/$(id -u)/com.example.autossh
launchctl kickstart -k gui/$(id -u)/com.example.autossh

plist 是 launchd 的服务定义文件,是否随登录启动取决于是否被 launchctl 加载、是否启用,以及 RunAtLoadKeepAlive 等字段。