diff --git a/src/backend/database/routes/ssh.ts b/src/backend/database/routes/ssh.ts index 9304a647..94407726 100644 --- a/src/backend/database/routes/ssh.ts +++ b/src/backend/database/routes/ssh.ts @@ -91,7 +91,7 @@ router.get("/db/host/internal", async (req: Request, res: Response) => { username: host.username, password: host.autostartPassword, key: host.autostartKey, - key_password: host.autostartKeyPassword, + keyPassword: host.autostartKeyPassword, autostartPassword: host.autostartPassword, autostartKey: host.autostartKey, autostartKeyPassword: host.autostartKeyPassword, @@ -151,7 +151,7 @@ router.get("/db/host/internal/all", async (req: Request, res: Response) => { username: host.username, password: host.autostartPassword || host.password, key: host.autostartKey || host.key, - key_password: host.autostartKeyPassword || host.key_password, + keyPassword: host.autostartKeyPassword || host.key_password, autostartPassword: host.autostartPassword, autostartKey: host.autostartKey, autostartKeyPassword: host.autostartKeyPassword, @@ -226,7 +226,7 @@ router.post( authType, credentialId, key, - key_password, + keyPassword, keyType, pin, enableTerminal, @@ -278,7 +278,7 @@ router.post( sshDataObj.keyType = null; } else if (effectiveAuthType === "key") { sshDataObj.key = key || null; - sshDataObj.key_password = key_password || null; + sshDataObj.key_password = keyPassword || null; sshDataObj.keyType = keyType; sshDataObj.password = null; } else { @@ -407,7 +407,7 @@ router.put( authType, credentialId, key, - key_password, + keyPassword, keyType, pin, enableTerminal, @@ -464,8 +464,8 @@ router.put( if (key) { sshDataObj.key = key; } - if (key_password !== undefined) { - sshDataObj.key_password = key_password || null; + if (keyPassword !== undefined) { + sshDataObj.key_password = keyPassword || null; } if (keyType) { sshDataObj.keyType = keyType; @@ -1234,12 +1234,19 @@ async function resolveHostCredentials(host: any): Promise { authType: credential.auth_type || credential.authType, password: credential.password, key: credential.key, - key_password: credential.key_password || credential.key_password, + keyPassword: credential.key_password || credential.keyPassword, keyType: credential.key_type || credential.keyType, }; } } - return host; + + // Convert snake_case to camelCase for hosts without credentials + const result = { ...host }; + if (host.key_password !== undefined) { + result.keyPassword = host.key_password; + delete result.key_password; + } + return result; } catch (error) { sshLogger.warn( `Failed to resolve credentials for host ${host.id}: ${error instanceof Error ? error.message : "Unknown error"}`, diff --git a/src/backend/ssh/server-stats.ts b/src/backend/ssh/server-stats.ts index f580bb96..cc8c7e29 100644 --- a/src/backend/ssh/server-stats.ts +++ b/src/backend/ssh/server-stats.ts @@ -478,7 +478,7 @@ async function resolveHostCredentials( function addLegacyCredentials(baseHost: any, host: any): void { baseHost.password = host.password || null; baseHost.key = host.key || null; - baseHost.keyPassword = host.keyPassword || null; + baseHost.keyPassword = host.key_password || host.keyPassword || null; baseHost.keyType = host.keyType; }