In attempts to run a self sustaining reverse ssh tunnel I have tried installing the 'autossh' package with brew. Autossh works alone when ran through the user's prompt, but not with launchctl/launchd.


<?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">

/Users/user/Public/tunnel.sh (with executable bit set)

/usr/local/Cellar/autossh/1.4e/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -R 5000:localhost:22 user@domain.com

launchctl load /Lib*/LaunchDaemons/*autossh.plist

Any alternatives other than autossh/launchd are yet to be found.

  • 1
    are you sure your script is launched within the correct user? ssh keys and connection settings are stored in user home dir and may not be available in user who is used for launchctl/launchd. – rush Apr 24 '16 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.