using launchd to create "on demand" ssh tunnel
I've setup 2 LaunchAgents in my ~/Library/LaunchAgents/ directory, in order to provide 2 apps with an ssh tunnel connectivity "on demand".
One of the plist is like this :
<?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>Debug</key>
<false/>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>my.ssh.tunnel</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ssh</string>
<string>-l</string>
<string>mylogin</string>
<string>-N</string>
<string>-L</string>
<string>port:final-server:port</string>
<string>mylogin@ssh-gateway</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>Bonjour</key>
<false/>
<key>SockServiceName</key>
<string>port</string>
<key>SockType</key>
<string>stream</string>
</dict>
</dict>
<key>StandardErrorPath</key>
<string>/tmp/mytunnel.err</string>
<key>StandardOutPath</key>
<string>/tmp/mytunnel.out</string>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>onDemand</key>
<true/>
</dict>
</plist>
When I launch the application that makes a tcp request on localhost:port, the tunnel is created, this part is OK. But, the application is unable to use it. I have to quit and restart it so that it can use the ssh tunnel.
Any idea why it behaves like this ? Any workaround ?
PowerMac G5 2*2GHz Mac OS X (10.4.6)