From e90b98e629dbce6b89c2492030598d8873b3f4d4 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:51:40 -0600 Subject: [PATCH] refactor: add warning when using keyboard interactive --- .../dokploy/server/utils/process/execAsync.ts | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/apps/dokploy/server/utils/process/execAsync.ts b/apps/dokploy/server/utils/process/execAsync.ts index 8c8fdc19..87e278d6 100644 --- a/apps/dokploy/server/utils/process/execAsync.ts +++ b/apps/dokploy/server/utils/process/execAsync.ts @@ -24,31 +24,41 @@ export const execAsyncRemote = async ( conn .once("ready", () => { console.log("Client :: ready"); - conn.exec(command, (err, stream) => { - if (err) throw err; - stream - .on("close", (code: number, signal: string) => { - console.log( - `Stream :: close :: code: ${code}, signal: ${signal}`, - ); - conn.end(); - if (code === 0) { - resolve({ stdout, stderr }); - } else { - reject( - new Error( - `Command exited with code ${code}. Stderr: ${stderr}, command: ${command}`, - ), + conn + .exec(command, (err, stream) => { + if (err) throw err; + stream + .on("close", (code: number, signal: string) => { + console.log( + `Stream :: close :: code: ${code}, signal: ${signal}`, ); - } - }) - .on("data", (data: string) => { - stdout += data.toString(); - }) - .stderr.on("data", (data) => { - stderr += data.toString(); - }); - }); + conn.end(); + if (code === 0) { + resolve({ stdout, stderr }); + } else { + reject( + new Error( + `Command exited with code ${code}. Stderr: ${stderr}, command: ${command}`, + ), + ); + } + }) + .on("data", (data: string) => { + stdout += data.toString(); + }) + .stderr.on("data", (data) => { + stderr += data.toString(); + }); + }) + .on("keyboard-interactive", () => { + console.log("Warning: Keyboard interactive, closing connection"); + conn.end(); + reject( + new Error( + "Password requested. Invalid SSH key or authentication issue.", + ), + ); + }); }) .connect({ host: server.ipAddress,