Reputation: 236
I'm running autossh on a 2010 MBA running Mavericks. The script runs fine and works as expected from the command line, but not when run by launchd.
I have tried including PATH in the launchd plist, but that didn't help.
Here's the script:
#!/bin/bash
/opt/local/bin/autossh -M 0 -f -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure yes" -R 19990:localhost:22 [email protected] -p 10000
I've tried with and without "ExitOnForwardFailure yes"
Here's the plist:
<?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>
I've tried with and without the PATH key.
I want to be able to log in to this machine remotely. I have also tried this using just ssh and it runs fine from the command line and from launchd:
#!/bin/bash
ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 19999:172.16.0.56:22 [email protected] -p 10000
Of course, since ssh works I don't actually need autossh, but I would like to know why it doesn't work for me.
Upvotes: 2
Views: 726
Reputation: 236
Working now. Turns out to get it to work with launchd I had to add two parameters to the shell script: "-f" to run in the background and "-N" execute no command. I have no idea why this worked.
#!/bin/bash
/opt/local/bin/autossh -f -M 0 -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 19990:localhost:22 [email protected] -p 10000
Upvotes: 0