mirror of
https://cgit.krebsco.de/krops
synced 2024-12-23 10:19:52 +01:00
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
This commit is contained in:
parent
8de797dae0
commit
70fa39607f
3 changed files with 10 additions and 8 deletions
|
@ -44,7 +44,7 @@ let {
|
|||
|
||||
mkTarget = s: let
|
||||
default = defVal: val: if val != null then val else defVal;
|
||||
parse = lib.match "(([^@]+)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
|
||||
parse = lib.match "(([^@]*)@)?(([^:/]+))?(:([^/]+))?(/.*)?" s;
|
||||
elemAt' = xs: i: if lib.length xs > i then lib.elemAt xs i else null;
|
||||
in if lib.isString s then {
|
||||
user = default (lib.getEnv "LOGNAME") (elemAt' parse 1);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue