From f3f18bfcb011bfbfcec478172614471ae2b94497 Mon Sep 17 00:00:00 2001 From: fabgo Date: Thu, 3 Oct 2024 08:24:08 -0700 Subject: [PATCH] ENG-2768 Print an error message if SSH fails to establish a connection (#127) Prints an error message if SSH fails to establish a connection. --- src/plugins/ssh/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/ssh/index.ts b/src/plugins/ssh/index.ts index a231892..d84ddbd 100644 --- a/src/plugins/ssh/index.ts +++ b/src/plugins/ssh/index.ts @@ -116,11 +116,6 @@ type SpawnSshNodeOptions = { isAccessPropagationPreTest?: boolean; }; -/** Starts an SSM session in the terminal by spawning `aws ssm` as a subprocess - * - * Requires `aws ssm` to be installed on the client machine. - */ - async function spawnSshNode( options: SpawnSshNodeOptions ): Promise { @@ -183,7 +178,15 @@ async function spawnSshNode( } options.abortController?.abort(code); - if (!options.isAccessPropagationPreTest) print2(`SSH session terminated`); + + if (code && code !== 0) { + print2( + `Failed to establish an SSH session.${!options.debug ? " Use the --debug option to see additional details." : ""}` + ); + } else if (!options.isAccessPropagationPreTest) { + print2(`SSH session terminated`); + } + resolve(code); }); }); @@ -386,8 +389,10 @@ export const sshOrScp = async (args: { proxyCommand, credential ); + + // Only exit if there was an error when pre-testing if (exitCode && exitCode !== 0) { - return exitCode; // Only exit if there was an error when pre-testing + return exitCode; } return spawnSshNode({