Commit | Line | Data |
47c83a13 |
1 | package Object::Remote::Connector::SSH; |
2 | |
84b04178 |
3 | use Object::Remote::ModuleSender; |
8ba4f2e3 |
4 | use Object::Remote::Handle; |
47c83a13 |
5 | use Moo; |
6 | |
a9fdb55e |
7 | with 'Object::Remote::Role::Connector::PerlInterpreter'; |
47c83a13 |
8 | |
a9fdb55e |
9 | around _perl_command => sub { |
10 | my ($orig, $self, $target) = @_; |
11 | return 'ssh', $target, $self->$orig($target); |
84b04178 |
12 | }; |
13 | |
47c83a13 |
14 | sub _ssh_object_for { |
15 | my ($self, $on) = @_; |
16 | $self->ssh_masters->{$on} ||= Net::OpenSSH->new($on); |
17 | } |
18 | |
84b04178 |
19 | push @Object::Remote::Connection::Guess, sub { |
20 | for ($_[0]) { |
21 | # 0-9 a-z _ - first char, those or . subsequent - hostnamish |
a9fdb55e |
22 | if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) { |
84b04178 |
23 | return __PACKAGE__->new->connect($_[0]); |
24 | } |
25 | } |
26 | return; |
27 | }; |
28 | |
47c83a13 |
29 | 1; |