From 70fa39607fa9f0d7df424588ae109968f0f876d1 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 29 Nov 2019 00:01:37 +0100 Subject: ssh: support using ssh-configured user Let ssh use the user configured in its configuration files when the target user is set to the empty string. Closes https://github.com/krebs/krops/issues/2 --- pkgs/krops/default.nix | 4 ++-- pkgs/populate/default.nix | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'pkgs') diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix index e72e94c..2c12015 100644 --- a/pkgs/krops/default.nix +++ b/pkgs/krops/default.nix @@ -20,9 +20,9 @@ in remoteCommand = target: command: exec "build.${target.host}" rec { filename = "${openssh}/bin/ssh"; - argv = [ + argv = lib.flatten [ filename - "-l" target.user + (lib.optionals (target.user != "") ["-l" target.user]) "-p" target.port "-t" target.host diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index 8a383b1..2b283a8 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -163,8 +163,10 @@ let --delete-excluded \ "$source_path" \ ${quote ( - optionalString (!isLocalTarget target) - "${target.user}@${target.host}:" + + optionalString (!isLocalTarget target) ( + (optionalString (target.user != "") "${target.user}@") + + "${target.host}:" + ) + target.path )} \ >&2 @@ -180,13 +182,13 @@ let ${ssh' target} ${quote target.host} ${quote script} ''; - ssh' = target: concatMapStringsSep " " quote [ + ssh' = target: concatMapStringsSep " " quote (flatten [ "${openssh}/bin/ssh" - "-l" target.user + (optionals (target.user != "") ["-l" target.user]) "-o" "ControlPersist=no" "-p" target.port "-T" - ]; + ]); in -- cgit v1.2.3