From d99e961330cb4d27cc2a9007095161ff04a360e5 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Tue, 9 Feb 2021 15:23:42 +0100 Subject: [PATCH] Add ssh2 debug option --- src/connect.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/connect.ts b/src/connect.ts index fc624b1..88d6cfd 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -222,7 +222,12 @@ export async function createSSH(config: FileSystemConfig, sock?: NodeJS.Readable }); try { logging.info(`Creating SSH session over the opened socket`); - client.connect(Object.assign(config, { sock }, DEFAULT_CONFIG)); + let debug = (_msg: string) => {}; + if (config.debug) { + const scope = Logging.scope(`ssh2(${config.name})`); + debug = (msg: string) => scope.debug(msg); + } + client.connect(Object.assign(config, { sock, debug }, DEFAULT_CONFIG)); } catch (e) { reject(e); }