SSH options as a separate argument for the SSH connector
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / SSH.pm
CommitLineData
47c83a13 1package Object::Remote::Connector::SSH;
2
84b04178 3use Object::Remote::ModuleSender;
8ba4f2e3 4use Object::Remote::Handle;
47c83a13 5use Moo;
6
a9fdb55e 7with 'Object::Remote::Role::Connector::PerlInterpreter';
47c83a13 8
fbd3b8ec 9has ssh_to => (is => 'ro', required => 1);
10
498c4ad5 11has ssh_perl_command => (is => 'lazy');
12
6ec765ba 13has ssh_options => (is => 'ro', default => sub { [ '-A' ] });
14
15has ssh_command => (is => 'ro', default => sub { 'ssh' });
16
498c4ad5 17sub _build_ssh_perl_command {
18 my ($self) = @_;
6ec765ba 19 return [
20 do { my $c = $self->ssh_command; ref($c) ? @$c : $c },
21 @{$self->ssh_options}, $self->ssh_to,
22 @{$self->perl_command}
23 ];
498c4ad5 24}
25
26sub final_perl_command { shift->ssh_perl_command }
84b04178 27
7efea51f 28no warnings 'once';
29
84b04178 30push @Object::Remote::Connection::Guess, sub {
31 for ($_[0]) {
32 # 0-9 a-z _ - first char, those or . subsequent - hostnamish
a9fdb55e 33 if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) {
fbd3b8ec 34 return __PACKAGE__->new(ssh_to => $_[0]);
84b04178 35 }
36 }
37 return;
38};
39
47c83a13 401;