Skip to content

Instantly share code, notes, and snippets.

@shanmuha
Created March 13, 2017 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanmuha/d97e9f1abdaf1c9b804f748f332a3ffd to your computer and use it in GitHub Desktop.
Save shanmuha/d97e9f1abdaf1c9b804f748f332a3ffd to your computer and use it in GitHub Desktop.
ssh redirect launchd daemon for osx sierra
<?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>org.teesh.sshdredirect</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>62010</string>
<key>SockType</key>
<string>stream</string>
<key>SockFamily</key>
<string>IPv4</string>
</dict>
</dict>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/socat</string>
<string>TCP-LISTEN:62010,reuseaddr,fork</string>
<string>TCP:localhost:22</string>
</array>
<key>StandardOutPath</key>
<string>/var/log/redirectssh.log</string>
<key>StandardErrorPath</key>
<string>/var/log/redirectssh.log</string>
<key>Debug</key>
<true/>
</dict>
</plist>
@bowmasters
Copy link

bowmasters commented Aug 17, 2017

Adding the socket listener on port 62010 as you did here will cause the socat command to fail as it won't be able to bind to a port that is already in use. I recommend removing the Sockets key:


<?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>org.teesh.sshdredirect</string>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/socat</string>
        <string>TCP-LISTEN:62010,reuseaddr,fork</string>
        <string>TCP:localhost:22</string>
    </array>
    <key>StandardOutPath</key>
    <string>/var/log/redirectssh.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/redirectssh.log</string>
    <key>Debug</key>
    <true/>
</dict>
</plist>

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