Added options to set ssh port.
ssh port can be set by passing the -sshport variable on the command line or by changing the $sshport variable.
This commit is contained in:
parent
17759ce659
commit
5b3693357e
13
syncoid
13
syncoid
|
@ -26,6 +26,7 @@ my $zfscmd = '/sbin/zfs';
|
||||||
my $sshcmd = '/usr/bin/ssh';
|
my $sshcmd = '/usr/bin/ssh';
|
||||||
my $pscmd = '/bin/ps';
|
my $pscmd = '/bin/ps';
|
||||||
my $sshcipher = '-c arcfour';
|
my $sshcipher = '-c arcfour';
|
||||||
|
my $sshport = '-p 22';
|
||||||
my $pvcmd = '/usr/bin/pv';
|
my $pvcmd = '/usr/bin/pv';
|
||||||
my $mbuffercmd = '/usr/bin/mbuffer';
|
my $mbuffercmd = '/usr/bin/mbuffer';
|
||||||
my $sudocmd = '/usr/bin/sudo';
|
my $sudocmd = '/usr/bin/sudo';
|
||||||
|
@ -34,12 +35,15 @@ my $mbufferoptions = '-q -s 128k -m 16M 2>/dev/null';
|
||||||
# being present on remote machines.
|
# being present on remote machines.
|
||||||
my $lscmd = '/bin/ls';
|
my $lscmd = '/bin/ls';
|
||||||
|
|
||||||
|
if ( $args{'sshport'} ) {
|
||||||
|
$sshport = "-p $args{'sshport'}";
|
||||||
|
}
|
||||||
# figure out if source and/or target are remote.
|
# figure out if source and/or target are remote.
|
||||||
if ( $args{'sshkey'} ) {
|
if ( $args{'sshkey'} ) {
|
||||||
$sshcmd = "$sshcmd $sshcipher -i $args{'sshkey'}";
|
$sshcmd = "$sshcmd $sshcipher $sshport -i $args{'sshkey'}";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sshcmd = "$sshcmd $sshcipher";
|
$sshcmd = "$sshcmd $sshcipher $sshport";
|
||||||
}
|
}
|
||||||
my ($sourcehost,$sourcefs,$sourceisroot) = getssh($rawsourcefs);
|
my ($sourcehost,$sourcefs,$sourceisroot) = getssh($rawsourcefs);
|
||||||
my ($targethost,$targetfs,$targetisroot) = getssh($rawtargetfs);
|
my ($targethost,$targetfs,$targetisroot) = getssh($rawtargetfs);
|
||||||
|
@ -254,7 +258,7 @@ sub getargs {
|
||||||
|
|
||||||
my %novaluearg;
|
my %novaluearg;
|
||||||
my %validarg;
|
my %validarg;
|
||||||
push my @validargs, ('debug','nocommandchecks','version','monitor-version','compress','source-bwlimit','target-bwlimit','dumpsnaps','recursive','r','sshkey');
|
push my @validargs, ('debug','nocommandchecks','version','monitor-version','compress','source-bwlimit','target-bwlimit','dumpsnaps','recursive','r','sshkey','sshport');
|
||||||
foreach my $item (@validargs) { $validarg{$item} = 1; }
|
foreach my $item (@validargs) { $validarg{$item} = 1; }
|
||||||
push my @novalueargs, ('debug','nocommandchecks','version','monitor-version','dumpsnaps','recursive','r');
|
push my @novalueargs, ('debug','nocommandchecks','version','monitor-version','dumpsnaps','recursive','r');
|
||||||
foreach my $item (@novalueargs) { $novaluearg{$item} = 1; }
|
foreach my $item (@novalueargs) { $novaluearg{$item} = 1; }
|
||||||
|
@ -716,6 +720,7 @@ sub getssh {
|
||||||
my $rhost;
|
my $rhost;
|
||||||
my $isroot;
|
my $isroot;
|
||||||
my $socket;
|
my $socket;
|
||||||
|
|
||||||
# if we got passed something with an @ in it, we assume it's an ssh connection, eg root@myotherbox
|
# if we got passed something with an @ in it, we assume it's an ssh connection, eg root@myotherbox
|
||||||
if ($fs =~ /\@/) {
|
if ($fs =~ /\@/) {
|
||||||
$rhost = $fs;
|
$rhost = $fs;
|
||||||
|
@ -726,7 +731,7 @@ sub getssh {
|
||||||
if ($remoteuser eq 'root') { $isroot = 1; } else { $isroot = 0; }
|
if ($remoteuser eq 'root') { $isroot = 1; } else { $isroot = 0; }
|
||||||
# now we need to establish a persistent master SSH connection
|
# now we need to establish a persistent master SSH connection
|
||||||
$socket = "/tmp/syncoid-$remoteuser-$rhost-" . time();
|
$socket = "/tmp/syncoid-$remoteuser-$rhost-" . time();
|
||||||
open FH, "$sshcmd -M -S $socket -o ControlPersist=yes $rhost exit |";
|
open FH, "$sshcmd -M -S $socket -o ControlPersist=yes $sshport $rhost exit |";
|
||||||
close FH;
|
close FH;
|
||||||
$rhost = "-S $socket $rhost";
|
$rhost = "-S $socket $rhost";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue