Take me over?
NAME
App::PersistentSSH - Kick an ssh control master around on OSX using scutil
SYNOPSIS
% persisshtent --host your.host.com
DESCRIPTION
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.
CONFIGURATION
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.
Use 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>
ATTRIBUTES
- host
-
The host to connect to. Must be a valid ipaddress/hostname, not just an ssh config host entry.
- ssh_verbose
-
Pass
-v
to ssh. - ssh_opts
-
Additional options for ssh, useful for tunnelling etc.
METHODS
- new
- new_with_options
-
Spawn the POE component.
new_with_options
comes from MooseX::Getopt. - run
-
Calls "run" in POE::Kernel.
VERSION CONTROL
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.
AUTHOR
Yuval Kogman <nothingmuch@woobling.org>
COPYRIGHT
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.