From 5b3693357e79f2d2bdbcb8baadf1a686d093349a Mon Sep 17 00:00:00 2001 From: Albin Gustavsson Date: Thu, 26 May 2016 20:30:24 +0200 Subject: [PATCH 1/2] 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. --- syncoid | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/syncoid b/syncoid index c3892b4..cd7ac06 100755 --- a/syncoid +++ b/syncoid @@ -26,6 +26,7 @@ my $zfscmd = '/sbin/zfs'; my $sshcmd = '/usr/bin/ssh'; my $pscmd = '/bin/ps'; my $sshcipher = '-c arcfour'; +my $sshport = '-p 22'; my $pvcmd = '/usr/bin/pv'; my $mbuffercmd = '/usr/bin/mbuffer'; my $sudocmd = '/usr/bin/sudo'; @@ -34,12 +35,15 @@ my $mbufferoptions = '-q -s 128k -m 16M 2>/dev/null'; # being present on remote machines. my $lscmd = '/bin/ls'; +if ( $args{'sshport'} ) { + $sshport = "-p $args{'sshport'}"; +} # figure out if source and/or target are remote. if ( $args{'sshkey'} ) { - $sshcmd = "$sshcmd $sshcipher -i $args{'sshkey'}"; + $sshcmd = "$sshcmd $sshcipher $sshport -i $args{'sshkey'}"; } else { - $sshcmd = "$sshcmd $sshcipher"; + $sshcmd = "$sshcmd $sshcipher $sshport"; } my ($sourcehost,$sourcefs,$sourceisroot) = getssh($rawsourcefs); my ($targethost,$targetfs,$targetisroot) = getssh($rawtargetfs); @@ -254,7 +258,7 @@ sub getargs { my %novaluearg; 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; } push my @novalueargs, ('debug','nocommandchecks','version','monitor-version','dumpsnaps','recursive','r'); foreach my $item (@novalueargs) { $novaluearg{$item} = 1; } @@ -716,6 +720,7 @@ sub getssh { my $rhost; my $isroot; my $socket; + # if we got passed something with an @ in it, we assume it's an ssh connection, eg root@myotherbox if ($fs =~ /\@/) { $rhost = $fs; @@ -726,7 +731,7 @@ sub getssh { if ($remoteuser eq 'root') { $isroot = 1; } else { $isroot = 0; } # now we need to establish a persistent master SSH connection $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; $rhost = "-S $socket $rhost"; } else { From dd4ef0fa533e5d7db42423f1220050ef564bdc3b Mon Sep 17 00:00:00 2001 From: Jim Salter Date: Fri, 27 May 2016 18:57:55 -0400 Subject: [PATCH 2/2] 1.4.6c merge @gusson's --sshport argument for syncoid --- CHANGELIST | 7 +++++++ findoid | 2 +- sanoid | 2 +- syncoid | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELIST b/CHANGELIST index c32528f..873c90a 100644 --- a/CHANGELIST +++ b/CHANGELIST @@ -1,3 +1,10 @@ +1.4.6c merged @gusson's pull request to add -sshport argument + +1.4.6b updated default cipherlist for syncoid to + chacha20-poly1305@openssh.com,arcfour - arcfour isn't supported on + newer SSH (in Ubuntu Xenial and FreeBSD), chacha20 isn't supported on + some older SSH versions (Ubuntu Precise< I think?) + 1.4.6a due to bug in ZFS on Linux which frequently causes errors to return from `zfs set readonly`, changed ==0 or die in setzfsvalue() to ==0 or [complain] - it's not worth causing replication to fail while this ZFS on Linux bug exists. diff --git a/findoid b/findoid index b00b81a..a7121d5 100755 --- a/findoid +++ b/findoid @@ -11,7 +11,7 @@ use warnings; my $zfs = '/sbin/zfs'; my %args = getargs(@ARGV); -my $progversion = '1.4.6a'; +my $progversion = '1.4.6c'; if ($args{'version'}) { print "$progversion\n"; exit 0; } diff --git a/sanoid b/sanoid index 8c3e013..fe50d61 100755 --- a/sanoid +++ b/sanoid @@ -4,7 +4,7 @@ # from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this # project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE. -my $version = '1.4.6a'; +my $version = '1.4.6c'; use strict; use Config::IniFiles; # read samba-style conf file diff --git a/syncoid b/syncoid index cd7ac06..cf3616c 100755 --- a/syncoid +++ b/syncoid @@ -4,7 +4,7 @@ # from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this # project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE. -my $version = '1.4.6a'; +my $version = '1.4.6c'; use strict; use Data::Dumper; @@ -25,7 +25,7 @@ my $debug = $args{'debug'}; my $zfscmd = '/sbin/zfs'; my $sshcmd = '/usr/bin/ssh'; my $pscmd = '/bin/ps'; -my $sshcipher = '-c arcfour'; +my $sshcipher = '-c chacha20-poly1305@openssh.com,arcfour'; my $sshport = '-p 22'; my $pvcmd = '/usr/bin/pv'; my $mbuffercmd = '/usr/bin/mbuffer';