My favorites | Sign in
Project Logo
                
Search
for
Updated Dec 16, 2008 by adamsc
Labels: example, crankd
SOCKSProxyExample  

SOCKS Proxy Example

As an example of the options the native API opens up, this demonstrates the ability to modify the system proxy settings based on runtime information to enable the use of an OpenSSH Dynamic Proxy when the user is not on the campus network:

Prerequisites

  1. Configure public key authentication for your account so it can be used without interaction (i.e. 10.5's SSH agent for authentication, username set in ~/.ssh/config, etc.). As long as something like ssh myserver.example.org date works you should be fine.
  2. Register a LaunchAgent so launchd will keep your SSH connection open as long as you're logged in:
    1. Copy org.openssh.dynamic-proxy.plist to ~/Library/LaunchAgents (note that you must already have public key authentication configured)
    2. Change server.example.org to your server
    3. Register the LaunchAgent with launchd for interactive (aqua) sessions: launchctl -w -S aqua load ~/Library/LaunchAgents/org.openssh.dynamic-proxy.plist

Manual Install

  1. Copy or symlink crankd.py in /usr/local/sbin
  2. Copy or symlink the http://pymacadmin.googlecode.com/svn/trunk/lib/PyMacAdmin/PyMacAdmin to /Library/Application Support/crankd/PyMacAdmin
  3. Copy or symlink the ProxyManager.py to /Library/Application Support/crankd/
  4. Copy com.googlecode.pymacadmin.crankd.plist to /Library/Preferences
  5. Copy com.googlecode.pymacadmin.crankd.LaunchDaemon.plist to /Library/LaunchDaemons
  6. Register the launch daemon with launchd: launchctl load -w /Library/LaunchDaemons/com.googlecode.pymacadmin.crankd.LaunchDaemon.plist
  7. Open Console.app - you should see various startup messages as crankd loads
  8. Put your system to sleep and wake it. After it wakes, your network preferences should have the SOCKS proxy enabled using localhost:1080

Comment by tperfitt, Oct 15, 2008

Step 6 is incorrect. You need the "load" first:

launchctl load -w -S aqua /Library/LaunchDaemons?/com.googlecode.pymacadmin.crankd.LaunchDaemon?.plist

Also, not sure why you need the -S aqua.

Comment by adamsc, Dec 16, 2008

@tperfitt: thanks for the correction. The -S aqua made sense in the SSH proxy context because most people have their SSH keys stored in the keychain with 10.5; it appears to be completely ignored for LaunchDaemons? so I missed omitting it when compiling the commands for this post.


Sign in to add a comment
Hosted by Google Code