App::PersistentSSH - Kick an ssh control master around on OSX using scutil
% persisshtent --host your.host.com
This POE component will keep an SSH control master alive, depending on network status.
It uses the OSX command line tool scutil to get notification on changes to the
State:/Network/Global/IPv4 configuration key. Whenever this key is changed
scutil -r will be used to check if the specified host is directly reachable (without creating a connection using e.g. PPP), and if so spawn ssh.
If the host is not reachable, ssh is stopped.
Add something alongs the lines of
Host * ControlPath /tmp/%r@%h:%p
to your ssh_config, in order to configure the path that the ssh control master will bind on.
ControlMaster auto is not needed.
The advantage over
ControlMaster auto is that if you close your initial ssh, which is the control master under
auto all subsequently made connections will also close. By keeping a daemonized, managed instance of
ssh this problem is avoided.
ssh -v yourhost to verify that the connection really is going through the control master.
You can create a launchd service for this using http://lingon.sourceforge.net/. I use:
<key>Disabled</key> <false/> <key>KeepAlive</key> <true/> <key>Label</key> <string>pasta ssh</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/perl</string> <string>/Users/nothingmuch/Perl/App-PersistentSSH/bin/persisshtent</string> <string>--verbose</string> <string>--host</string> <string>pasta.woobling.org</string> </array>
The host to connect to. Must be a valid ipaddress/hostname, not just an ssh config host entry.
Additional options for ssh, useful for tunnelling etc.
Spawn the POE component.
new_with_optionscomes from MooseX::Getopt.
Calls "run" in POE::Kernel.
This module is maintained using Darcs. You can get the latest version from http://nothingmuch.woobling.org/code, and use
darcs send to commit changes.
Yuval Kogman <email@example.com>
Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.