From 82b3c901dc62f958b67a051a1e671a3c7113b392 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 28 Oct 2024 17:55:49 +0700 Subject: [PATCH] ssh: fix ssh connections failing due to missing stdin --- pkgs/clan-cli/clan_cli/ssh/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/ssh/__init__.py b/pkgs/clan-cli/clan_cli/ssh/__init__.py index 8c47194b4..498c5be41 100644 --- a/pkgs/clan-cli/clan_cli/ssh/__init__.py +++ b/pkgs/clan-cli/clan_cli/ssh/__init__.py @@ -327,6 +327,7 @@ class Host: cwd: None | str | Path = None, check: bool = True, timeout: float = math.inf, + needs_user_terminal: bool = False, ) -> subprocess.CompletedProcess[str]: if extra_env is None: extra_env = {} @@ -367,9 +368,10 @@ class Host: stderr=stderr_write, env=env, cwd=cwd, - start_new_session=True, + start_new_session=not needs_user_terminal, ) as p: - stack.enter_context(terminate_process_group(p)) + if not needs_user_terminal: + stack.enter_context(terminate_process_group(p)) if write_std_fd is not None: write_std_fd.close() if write_err_fd is not None: @@ -517,6 +519,8 @@ class Host: cwd=cwd, check=check, timeout=timeout, + # all ssh commands can potentially ask for a password + needs_user_terminal=True, ) def nix_ssh_env(self, env: dict[str, str] | None) -> dict[str, str]: