Skip to content

Instantly share code, notes, and snippets.

@ericboehs
Created March 9, 2021 18:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericboehs/c5a65f9f9f5e8ce27b7f5c00dd7d515a to your computer and use it in GitHub Desktop.
Save ericboehs/c5a65f9f9f5e8ce27b7f5c00dd7d515a to your computer and use it in GitHub Desktop.
LaunchAgent for continually connecting to SOCKS via autossh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>gov.va.socks</string>
<key>KeepAlive</key>
<dict>
<key>NetworkState</key>
<true/>
</dict>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/autossh</string>
<string>-v</string>
<string>-M</string>
<string>20001</string>
<string>-D</string>
<string>2001</string>
<string>socks</string>
<string>-N</string>
</array>
<key>StandardOutPath</key>
<string>/Users/ericboehs/Logs/autossh/autossh.stdout</string>
<key>StandardErrorPath</key>
<string>/Users/ericboehs/Logs/autossh/autossh.stderr</string>
<key>User</key>
<string>ericboehs</string>
<key>ThrottleInterval</key>
<integer>30</integer>
</dict>
</plist>
@ericboehs
Copy link
Author

ericboehs commented Mar 9, 2021

Place this in ~/Library/LaunchAgents, update the paths from /Users/ericboehs to something that actually exists, and then run:

launchctl load -w ~/Library/LaunchAgents/gov.va.socks.plist

You'll want to make sure autossh is installed (brew install autossh) and if you're not on a M1 mac, you'll need to change line 16 to /usr/local/bin/autossh.

You'll also need to configure your socks host in ~/.ssh/config. But hopefully you've already done that.

@FernandoBoza
Copy link

Should the user add the plist pac url to their network proxy?

@ericboehs
Copy link
Author

That's what I prefer. But you could also use the omegaproxy extension in Chrome/Firefox. The autosshd solution presented here doesn't presuppose how you'll be connecting to the proxy, just getting the proxy running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment