mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor(server): throw error when authentication fails
This commit is contained in:
@@ -24,8 +24,7 @@ export const execAsyncRemote = async (
|
|||||||
conn
|
conn
|
||||||
.once("ready", () => {
|
.once("ready", () => {
|
||||||
console.log("Client :: ready");
|
console.log("Client :: ready");
|
||||||
conn
|
conn.exec(command, (err, stream) => {
|
||||||
.exec(command, (err, stream) => {
|
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
stream
|
stream
|
||||||
.on("close", (code: number, signal: string) => {
|
.on("close", (code: number, signal: string) => {
|
||||||
@@ -49,16 +48,19 @@ export const execAsyncRemote = async (
|
|||||||
.stderr.on("data", (data) => {
|
.stderr.on("data", (data) => {
|
||||||
stderr += data.toString();
|
stderr += data.toString();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.on("keyboard-interactive", () => {
|
.on("error", (err) => {
|
||||||
console.log("Warning: Keyboard interactive, closing connection");
|
|
||||||
conn.end();
|
conn.end();
|
||||||
|
if (err.level === "client-authentication") {
|
||||||
reject(
|
reject(
|
||||||
new Error(
|
new Error(
|
||||||
"Password requested. Invalid SSH key or authentication issue.",
|
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
} else {
|
||||||
|
reject(new Error(`SSH connection error: ${err.message}`));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.connect({
|
.connect({
|
||||||
host: server.ipAddress,
|
host: server.ipAddress,
|
||||||
|
|||||||
@@ -107,6 +107,24 @@ const connectToServer = async (serverId: string, logPath: string) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
.on("error", (err) => {
|
||||||
|
client.end();
|
||||||
|
if (err.level === "client-authentication") {
|
||||||
|
writeStream.write(
|
||||||
|
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`,
|
||||||
|
);
|
||||||
|
reject(
|
||||||
|
new Error(
|
||||||
|
`Authentication failed: Invalid SSH private key. ❌ Error: ${err.message} ${err.level}`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
writeStream.write(
|
||||||
|
`SSH connection error: ${err.message} ${err.level}`,
|
||||||
|
);
|
||||||
|
reject(new Error(`SSH connection error: ${err.message}`));
|
||||||
|
}
|
||||||
|
})
|
||||||
.connect({
|
.connect({
|
||||||
host: server.ipAddress,
|
host: server.ipAddress,
|
||||||
port: server.port,
|
port: server.port,
|
||||||
|
|||||||
Reference in New Issue
Block a user