From c151703837ba618944fb3779dccaa43d2d869d42 Mon Sep 17 00:00:00 2001 From: "git@end.re" Date: Thu, 8 Apr 2021 15:01:45 +0200 Subject: [PATCH] Implementing support for ssh_config(5) files --- syncoid | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/syncoid b/syncoid index 3f112de..c0f98e8 100755 --- a/syncoid +++ b/syncoid @@ -20,9 +20,9 @@ my $pvoptions = "-p -t -e -r -b"; # Blank defaults to use ssh client's default # TODO: Merge into a single "sshflags" option? -my %args = ('sshkey' => '', 'sshport' => '', 'sshcipher' => '', 'sshoption' => [], 'target-bwlimit' => '', 'source-bwlimit' => ''); +my %args = ('sshconfig' => '', 'sshkey' => '', 'sshport' => '', 'sshcipher' => '', 'sshoption' => [], 'target-bwlimit' => '', 'source-bwlimit' => ''); GetOptions(\%args, "no-command-checks", "monitor-version", "compress=s", "dumpsnaps", "recursive|r", "sendoptions=s", "recvoptions=s", - "source-bwlimit=s", "target-bwlimit=s", "sshkey=s", "sshport=i", "sshcipher|c=s", "sshoption|o=s@", + "source-bwlimit=s", "target-bwlimit=s", "sshconfig=s", "sshkey=s", "sshport=i", "sshcipher|c=s", "sshoption|o=s@", "debug", "quiet", "no-stream", "no-sync-snap", "no-resume", "exclude=s@", "skip-parent", "identifier=s", "no-clone-handling", "no-privilege-elevation", "force-delete", "no-clone-rollback", "no-rollback", "create-bookmark", "pv-options=s" => \$pvoptions, "keep-sync-snap", "preserve-recordsize", @@ -108,6 +108,9 @@ if (length $args{'sshcipher'}) { if (length $args{'sshport'}) { $args{'sshport'} = "-p $args{'sshport'}"; } +if (length $args{'sshconfig'}) { + $args{'sshconfig'} = "-F $args{'sshconfig'}"; +} if (length $args{'sshkey'}) { $args{'sshkey'} = "-i $args{'sshkey'}"; } @@ -125,7 +128,7 @@ if (length $args{'identifier'}) { } # figure out if source and/or target are remote. -$sshcmd = "$sshcmd $args{'sshcipher'} $sshoptions $args{'sshport'} $args{'sshkey'}"; +$sshcmd = "$sshcmd $args{'sshconfig'} $args{'sshcipher'} $sshoptions $args{'sshport'} $args{'sshkey'}"; if ($debug) { print "DEBUG: SSHCMD: $sshcmd\n"; } my ($sourcehost,$sourcefs,$sourceisroot) = getssh($rawsourcefs); my ($targethost,$targetfs,$targetisroot) = getssh($rawtargetfs); @@ -1978,6 +1981,7 @@ Options: --exclude=REGEX Exclude specific datasets which match the given regular expression. Can be specified multiple times --sendoptions=OPTIONS Use advanced options for zfs send (the arguments are filtered as needed), e.g. syncoid --sendoptions="Lc e" sets zfs send -L -c -e ... --recvoptions=OPTIONS Use advanced options for zfs receive (the arguments are filtered as needed), e.g. syncoid --recvoptions="ux recordsize o compression=lz4" sets zfs receive -u -x recordsize -o compression=lz4 ... + --sshconfig=FILE Specifies an ssh_config(5) file to be used --sshkey=FILE Specifies a ssh key to use to connect --sshport=PORT Connects to remote on a particular port --sshcipher|c=CIPHER Passes CIPHER to ssh to use a particular cipher set