我在运行 Mavericks 的 2010 MBA 上运行 autossh。该脚本运行良好,并且可以从命令行按预期工作,但在由 launchd 运行时却不行。
我曾尝试在启动的 plist 中包含 PATH,但这没有帮助。
这是脚本:
#!/bin/bash
/opt/local/bin/autossh -M 0 -f -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure yes" -R 19990:localhost:22 mnewman@super.myddns.rocks -p 10000
我试过有无“ExitOnForwardFailure yes”
这是列表:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
</string>
</dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mgnewman.autossh</string>
<key>ProgramArguments</key>
<array>
<string>/Users/mnewman/bin/autossh.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
我尝试过使用和不使用 PATH 键。
我希望能够远程登录到这台机器。我也尝试过仅使用 ssh 并在命令行和启动时运行良好:
#!/bin/bash
ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 19999:172.16.0.56:22 mnewman@super.myddns.rocks -p 10000
当然,由于 ssh 有效,我实际上并不需要 autossh,但我想知道为什么它对我不起作用。