Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(api): implemented ssh app connection

=8c56810f00c5
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 11534ea8cc..198d4b2717 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2558,6 +2558,15 @@ export const AppConnections = {
OCTOPUS_DEPLOY: {
instanceUrl: "The Octopus Deploy instance URL to connect to.",
apiKey: "The API key used to authenticate with Octopus Deploy."
+ },
+ SSH: {
+ host: "The hostname or IP address of the SSH server.",
+ port: "The port number of the SSH server (default: 22).",
+ username: "The username for SSH authentication.",
+ authMethod: "The authentication method to use (password or ssh-key).",
+ password: "The password for SSH authentication (required when authMethod is 'password').",
+ privateKey: "The private key in PEM format for SSH authentication (required when authMethod is 'ssh-key').",
+ passphrase: "The passphrase for the private key, if encrypted (optional, only for 'ssh-key' authMethod)."
}
}
};
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
index a67f2c0bf2..6105720335 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
@@ -119,6 +119,7 @@ import {
RenderConnectionListItemSchema,
SanitizedRenderConnectionSchema
} from "@app/services/app-connection/render/render-connection-schema";
+import { SanitizedSshConnectionSchema, SshConnectionListItemSchema } from "@app/services/app-connection/ssh";
import {
SanitizedSupabaseConnectionSchema,
SupabaseConnectionListItemSchema
@@ -185,7 +186,8 @@ const SanitizedAppConnectionSchema = z.union([
...SanitizedLaravelForgeConnectionSchema.options,
...SanitizedChefConnectionSchema.options,
...SanitizedDNSMadeEasyConnectionSchema.options,
- ...SanitizedOctopusDeployConnectionSchema.options
+ ...SanitizedOctopusDeployConnectionSchema.options,
+ ...SanitizedSshConnectionSchema.options
]);
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
@@ -233,7 +235,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
LaravelForgeConnectionListItemSchema,
ChefConnectionListItemSchema,
DNSMadeEasyConnectionListItemSchema,
- OctopusDeployConnectionListItemSchema
+ OctopusDeployConnectionListItemSchema,
+ SshConnectionListItemSchema
]);
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.ts
index cf48378196..6a1ad4ad97 100644
--- a/backend/src/server/routes/v1/app-connection-routers/index.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts
@@ -39,6 +39,7 @@ import { registerPostgresConnectionRouter } from "./postgres-connection-router";
import { registerRailwayConnectionRouter } from "./railway-connection-router";
import { registerRedisConnectionRouter } from "./redis-connection-router";
import { registerRenderConnectionRouter } from "./render-connection-router";
+import { registerSshConnectionRouter } from "./ssh-connection-router";
import { registerSupabaseConnectionRouter } from "./supabase-connection-router";
import { registerTeamCityConnectionRouter } from "./teamcity-connection-router";
import { registerTerraformCloudConnectionRouter } from "./terraform-cloud-router";
@@ -94,5 +95,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
[AppConnection.Redis]: registerRedisConnectionRouter,
[AppConnection.MongoDB]: registerMongoDBConnectionRouter,
[AppConnection.Chef]: registerChefConnectionRouter,
- [AppConnection.OctopusDeploy]: registerOctopusDeployConnectionRouter
+ [AppConnection.OctopusDeploy]: registerOctopusDeployConnectionRouter,
+ [AppConnection.SSH]: registerSshConnectionRouter
};
diff --git a/backend/src/server/routes/v1/app-connection-routers/ssh-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/ssh-connection-router.ts
new file mode 100644
index 0000000000..ae6e6b27e7
--- /dev/null
+++ b/backend/src/server/routes/v1/app-connection-routers/ssh-connection-router.ts
@@ -0,0 +1,18 @@
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ CreateSshConnectionSchema,
+ SanitizedSshConnectionSchema,
+ UpdateSshConnectionSchema
+} from "@app/services/app-connection/ssh";
+
+import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+
+export const registerSshConnectionRouter = async (server: FastifyZodProvider) => {
+ registerAppConnectionEndpoints({
+ app: AppConnection.SSH,
+ server,
+ sanitizedResponseSchema: SanitizedSshConnectionSchema,
+ createSchema: CreateSshConnectionSchema,
+ updateSchema: UpdateSshConnectionSchema
+ });
+};
diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.ts
index 968d837b43..3474914220 100644
--- a/backend/src/services/app-connection/app-connection-enums.ts
+++ b/backend/src/services/app-connection/app-connection-enums.ts
@@ -43,7 +43,8 @@ export enum AppConnection {
LaravelForge = "laravel-forge",
Chef = "chef",
Northflank = "northflank",
- OctopusDeploy = "octopus-deploy"
+ OctopusDeploy = "octopus-deploy",
+ SSH = "ssh"
}
export enum AWSRegion {
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index e32e3f35f3..2b9ce06e75 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -140,6 +140,7 @@ import { getRailwayConnectionListItem, validateRailwayConnectionCredentials } fr
import { getRedisConnectionListItem, RedisConnectionMethod, validateRedisConnectionCredentials } from "./redis";
import { RenderConnectionMethod } from "./render/render-connection-enums";
import { getRenderConnectionListItem, validateRenderConnectionCredentials } from "./render/render-connection-fns";
+import { getSshConnectionListItem, SshConnectionMethod, validateSshConnectionCredentials } from "./ssh";
import {
getSupabaseConnectionListItem,
SupabaseConnectionMethod,
@@ -232,7 +233,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {
getOktaConnectionListItem(),
getRedisConnectionListItem(),
getMongoDBConnectionListItem(),
- getChefConnectionListItem()
+ getChefConnectionListItem(),
+ getSshConnectionListItem()
]
.filter((option) => {
switch (projectType) {
@@ -367,7 +369,8 @@ export const validateAppConnectionCredentials = async (
[AppConnection.Chef]: validateChefConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Redis]: validateRedisConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.MongoDB]: validateMongoDBConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.OctopusDeploy]: validateOctopusDeployConnectionCredentials as TAppConnectionCredentialsValidator
+ [AppConnection.OctopusDeploy]: validateOctopusDeployConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.SSH]: validateSshConnectionCredentials as TAppConnectionCredentialsValidator
};
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);
@@ -435,6 +438,10 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
return "App Role";
case LdapConnectionMethod.SimpleBind:
return "Simple Bind";
+ case SshConnectionMethod.Password:
+ return "Password";
+ case SshConnectionMethod.SshKey:
+ return "SSH Key";
case RenderConnectionMethod.ApiKey:
case ChecklyConnectionMethod.ApiKey:
case OctopusDeployConnectionMethod.ApiKey:
@@ -519,7 +526,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
[AppConnection.MongoDB]: platformManagedCredentialsNotSupported,
[AppConnection.LaravelForge]: platformManagedCredentialsNotSupported,
[AppConnection.Chef]: platformManagedCredentialsNotSupported,
- [AppConnection.OctopusDeploy]: platformManagedCredentialsNotSupported
+ [AppConnection.OctopusDeploy]: platformManagedCredentialsNotSupported,
+ [AppConnection.SSH]: platformManagedCredentialsNotSupported
};
export const enterpriseAppCheck = async (
diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.ts
index 0dfe2335e6..3e8f006f66 100644
--- a/backend/src/services/app-connection/app-connection-maps.ts
+++ b/backend/src/services/app-connection/app-connection-maps.ts
@@ -45,7 +45,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
[AppConnection.MongoDB]: "MongoDB",
[AppConnection.Chef]: "Chef",
[AppConnection.Northflank]: "Northflank",
- [AppConnection.OctopusDeploy]: "Octopus Deploy"
+ [AppConnection.OctopusDeploy]: "Octopus Deploy",
+ [AppConnection.SSH]: "SSH"
};
export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {
@@ -93,5 +94,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp
[AppConnection.MongoDB]: AppConnectionPlanType.Regular,
[AppConnection.Chef]: AppConnectionPlanType.Enterprise,
[AppConnection.Northflank]: AppConnectionPlanType.Regular,
- [AppConnection.OctopusDeploy]: AppConnectionPlanType.Regular
+ [AppConnection.OctopusDeploy]: AppConnectionPlanType.Regular,
+ [AppConnection.SSH]: AppConnectionPlanType.Regular
};
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 028053b4b3..99b0bef3ae 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -113,6 +113,7 @@ import { railwayConnectionService } from "./railway/railway-connection-service";
import { ValidateRedisConnectionCredentialsSchema } from "./redis";
import { ValidateRenderConnectionCredentialsSchema } from "./render/render-connection-schema";
import { renderConnectionService } from "./render/render-connection-service";
+import { ValidateSshConnectionCredentialsSchema } from "./ssh";
import { ValidateSupabaseConnectionCredentialsSchema } from "./supabase";
import { supabaseConnectionService } from "./supabase/supabase-connection-service";
import { ValidateTeamCityConnectionCredentialsSchema } from "./teamcity";
@@ -185,7 +186,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
[AppConnection.Redis]: ValidateRedisConnectionCredentialsSchema,
[AppConnection.MongoDB]: ValidateMongoDBConnectionCredentialsSchema,
[AppConnection.Chef]: ValidateChefConnectionCredentialsSchema,
- [AppConnection.OctopusDeploy]: ValidateOctopusDeployConnectionCredentialsSchema
+ [AppConnection.OctopusDeploy]: ValidateOctopusDeployConnectionCredentialsSchema,
+ [AppConnection.SSH]: ValidateSshConnectionCredentialsSchema
};
export const appConnectionServiceFactory = ({
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 2419a8db8f..d40975d36b 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -227,6 +227,12 @@ import {
TRenderConnectionInput,
TValidateRenderConnectionCredentialsSchema
} from "./render/render-connection-types";
+import {
+ TSshConnection,
+ TSshConnectionConfig,
+ TSshConnectionInput,
+ TValidateSshConnectionCredentialsSchema
+} from "./ssh";
import {
TSupabaseConnection,
TSupabaseConnectionConfig,
@@ -310,6 +316,7 @@ export type TAppConnection = { id: string } & (
| TMongoDBConnection
| TChefConnection
| TOctopusDeployConnection
+ | TSshConnection
);
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
@@ -362,6 +369,7 @@ export type TAppConnectionInput = { id: string } & (
| TMongoDBConnectionInput
| TChefConnectionInput
| TOctopusDeployConnectionInput
+ | TSshConnectionInput
);
export type TSqlConnectionInput =
@@ -431,7 +439,8 @@ export type TAppConnectionConfig =
| TRedisConnectionConfig
| TMongoDBConnectionConfig
| TChefConnectionConfig
- | TOctopusDeployConnectionConfig;
+ | TOctopusDeployConnectionConfig
+ | TSshConnectionConfig;
export type TValidateAppConnectionCredentialsSchema =
| TValidateAwsConnectionCredentialsSchema
@@ -478,7 +487,8 @@ export type TValidateAppConnectionCredentialsSchema =
| TValidateRedisConnectionCredentialsSchema
| TValidateMongoDBConnectionCredentialsSchema
| TValidateChefConnectionCredentialsSchema
- | TValidateOctopusDeployConnectionCredentialsSchema;
+ | TValidateOctopusDeployConnectionCredentialsSchema
+ | TValidateSshConnectionCredentialsSchema;
export type TListAwsConnectionKmsKeys = {
connectionId: string;
diff --git a/backend/src/services/app-connection/ssh/index.ts b/backend/src/services/app-connection/ssh/index.ts
new file mode 100644
index 0000000000..bc541e68c4
--- /dev/null
+++ b/backend/src/services/app-connection/ssh/index.ts
@@ -0,0 +1,4 @@
+export * from "./ssh-connection-enums";
+export * from "./ssh-connection-fns";
+export * from "./ssh-connection-schemas";
+export * from "./ssh-connection-types";
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-enums.ts b/backend/src/services/app-connection/ssh/ssh-connection-enums.ts
new file mode 100644
index 0000000000..ba4c6f7e69
--- /dev/null
+++ b/backend/src/services/app-connection/ssh/ssh-connection-enums.ts
@@ -0,0 +1,4 @@
+export enum SshConnectionMethod {
+ Password = "password",
+ SshKey = "ssh-key"
+}
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
new file mode 100644
index 0000000000..bb3e69dff9
--- /dev/null
+++ b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts
@@ -0,0 +1,122 @@
+import { Client, ConnectConfig } from "ssh2";
+
+import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";
+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
+import { BadRequestError } from "@app/lib/errors";
+import { GatewayProxyProtocol } from "@app/lib/gateway";
+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+import { SshConnectionMethod } from "./ssh-connection-enums";
+import { TSshConnection, TSshConnectionConfig } from "./ssh-connection-types";
+
+const SSH_TIMEOUT = 15_000;
+
+export const getSshConnectionListItem = () => {
+ return {
+ name: "SSH" as const,
+ app: AppConnection.SSH as const,
+ methods: Object.values(SshConnectionMethod) as [SshConnectionMethod.Password, SshConnectionMethod.SshKey]
+ };
+};
+
+export const getSshConnectionClient = async (
+ credentials: TSshConnection["credentials"],
+ targetHost: string,
+ targetPort: number
+): Promise<Client> => {
+ return new Promise((resolve, reject) => {
+ const client = new Client();
+
+ client.on("error", (err: Error) => {
+ client.destroy();
+ reject(new Error(`SSH Error: ${err.message}`));
+ });
+
+ client.on("ready", () => {
+ resolve(client);
+ });
+
+ client.on("timeout", () => {
+ client.destroy();
+ reject(new Error("SSH Connection Timeout"));
+ });
+
+ const connectConfig: ConnectConfig = {
+ host: targetHost,
+ port: targetPort,
+ username: credentials.username,
+ readyTimeout: SSH_TIMEOUT
+ };
+
+ // Handle auth method using discriminated union
+ if (credentials.authMethod === SshConnectionMethod.Password) {
+ connectConfig.password = credentials.password;
+ } else {
+ connectConfig.privateKey = credentials.privateKey;
+ if (credentials.passphrase) {
+ connectConfig.passphrase = credentials.passphrase;
+ }
+ }
+
+ client.connect(connectConfig);
+ });
+};
+
+export const executeWithPotentialGateway = async <T>(
+ config: TSshConnectionConfig,
+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
+ operation: (targetHost: string, targetPort: number) => Promise<T>
+): Promise<T> => {
+ const { gatewayId, credentials } = config;
+
+ if (gatewayId && gatewayV2Service) {
+ await blockLocalAndPrivateIpAddresses(`ssh://${credentials.host}:${credentials.port}`, true);
+
+ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
+ gatewayId,
+ targetHost: credentials.host,
+ targetPort: credentials.port
+ });
+
+ if (!platformConnectionDetails) {
+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });
+ }
+
+ return withGatewayV2Proxy(
+ async (proxyPort) => {
+ return operation("localhost", proxyPort);
+ },
+ {
+ protocol: GatewayProxyProtocol.Tcp,
+ relayHost: platformConnectionDetails.relayHost,
+ gateway: platformConnectionDetails.gateway,
+ relay: platformConnectionDetails.relay
+ }
+ );
+ }
+
+ // Non-gateway path - direct connection
+ await blockLocalAndPrivateIpAddresses(`ssh://${credentials.host}:${credentials.port}`, false);
+ return operation(credentials.host, credentials.port);
+};
+
+export const validateSshConnectionCredentials = async (
+ config: TSshConnectionConfig,
+ _gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">
+) => {
+ try {
+ await executeWithPotentialGateway(config, gatewayV2Service, async (targetHost, targetPort) => {
+ const client = await getSshConnectionClient(config.credentials, targetHost, targetPort);
+ client.destroy(); // Clean up after successful connection
+ });
+
+ return config.credentials;
+ } catch (error) {
+ throw new BadRequestError({
+ message: `Unable to validate connection: ${(error as Error)?.message ?? "verify credentials"}`
+ });
+ }
+};
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-schemas.ts b/backend/src/services/app-connection/ssh/ssh-connection-schemas.ts
new file mode 100644
index 0000000000..fe6b09e12c
--- /dev/null
+++ b/backend/src/services/app-connection/ssh/ssh-connection-schemas.ts
@@ -0,0 +1,102 @@
+import { z } from "zod";
+
+import { AppConnections } from "@app/lib/api-docs";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ BaseAppConnectionSchema,
+ GenericCreateAppConnectionFieldsSchema,
+ GenericUpdateAppConnectionFieldsSchema
+} from "@app/services/app-connection/app-connection-schemas";
+
+import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";
+import { SshConnectionMethod } from "./ssh-connection-enums";
+
+// Base credentials schema with common fields
+const SshConnectionBaseCredentialsSchema = z.object({
+ host: z.string().trim().min(1, "Host required").describe(AppConnections.CREDENTIALS.SSH.host),
+ port: z.coerce.number().int().min(1).max(65535).describe(AppConnections.CREDENTIALS.SSH.port),
+ username: z.string().trim().min(1, "Username required").describe(AppConnections.CREDENTIALS.SSH.username)
+});
+
+// Auth method specific schemas
+const SshPasswordAuthSchema = z.object({
+ authMethod: z.literal(SshConnectionMethod.Password).describe(AppConnections.CREDENTIALS.SSH.authMethod),
+ password: z.string().trim().min(1, "Password required").describe(AppConnections.CREDENTIALS.SSH.password)
+});
+
+const SshKeyAuthSchema = z.object({
+ authMethod: z.literal(SshConnectionMethod.SshKey).describe(AppConnections.CREDENTIALS.SSH.authMethod),
+ privateKey: z.string().trim().min(1, "Private key required").describe(AppConnections.CREDENTIALS.SSH.privateKey),
+ passphrase: z.string().trim().optional().describe(AppConnections.CREDENTIALS.SSH.passphrase)
+});
+
+// Full credentials schema combining base + auth method discriminated union
+export const SshConnectionCredentialsSchema = SshConnectionBaseCredentialsSchema.and(
+ z.discriminatedUnion("authMethod", [SshPasswordAuthSchema, SshKeyAuthSchema])
+);
+
+// Base connection schema
+const BaseSshConnectionSchema = BaseAppConnectionSchema.extend({
+ app: z.literal(AppConnection.SSH)
+});
+
+// Full connection schema
+export const SshConnectionSchema = BaseSshConnectionSchema.extend({
+ method: z.literal(SshConnectionMethod.Password).or(z.literal(SshConnectionMethod.SshKey)),
+ credentials: SshConnectionCredentialsSchema
+});
+
+// Sanitized credentials schema (excludes password/privateKey/passphrase)
+const SanitizedSshConnectionCredentialsSchema = SshConnectionBaseCredentialsSchema.extend({
+ authMethod: z.nativeEnum(SshConnectionMethod).describe(AppConnections.CREDENTIALS.SSH.authMethod)
+});
+
+// Sanitized schema (excludes sensitive fields) - must be discriminated union for router compatibility
+export const SanitizedSshConnectionSchema = z.discriminatedUnion("method", [
+ BaseSshConnectionSchema.extend({
+ method: z.literal(SshConnectionMethod.Password),
+ credentials: SanitizedSshConnectionCredentialsSchema
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.SSH]} (Password)` })),
+ BaseSshConnectionSchema.extend({
+ method: z.literal(SshConnectionMethod.SshKey),
+ credentials: SanitizedSshConnectionCredentialsSchema
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.SSH]} (SSH Key)` }))
+]);
+
+// Validation schema for credentials
+export const ValidateSshConnectionCredentialsSchema = z.object({
+ method: z
+ .literal(SshConnectionMethod.Password)
+ .or(z.literal(SshConnectionMethod.SshKey))
+ .describe(AppConnections.CREATE(AppConnection.SSH).method),
+ credentials: SshConnectionCredentialsSchema.describe(AppConnections.CREATE(AppConnection.SSH).credentials)
+});
+
+// Create connection schema
+export const CreateSshConnectionSchema = ValidateSshConnectionCredentialsSchema.and(
+ GenericCreateAppConnectionFieldsSchema(AppConnection.SSH, {
+ supportsGateways: true
+ })
+);
+
+// Update connection schema
+export const UpdateSshConnectionSchema = z
+ .object({
+ credentials: SshConnectionCredentialsSchema.optional().describe(
+ AppConnections.UPDATE(AppConnection.SSH).credentials
+ )
+ })
+ .and(
+ GenericUpdateAppConnectionFieldsSchema(AppConnection.SSH, {
+ supportsGateways: true
+ })
+ );
+
+// List item schema
+export const SshConnectionListItemSchema = z
+ .object({
+ name: z.literal("SSH"),
+ app: z.literal(AppConnection.SSH),
+ methods: z.nativeEnum(SshConnectionMethod).array()
+ })
+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.SSH] }));
diff --git a/backend/src/services/app-connection/ssh/ssh-connection-types.ts b/backend/src/services/app-connection/ssh/ssh-connection-types.ts
new file mode 100644
index 0000000000..ef06d7a310
--- /dev/null
+++ b/backend/src/services/app-connection/ssh/ssh-connection-types.ts
@@ -0,0 +1,25 @@
+import { z } from "zod";
+
+import { DiscriminativePick } from "@app/lib/types";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+import {
+ CreateSshConnectionSchema,
+ SshConnectionSchema,
+ ValidateSshConnectionCredentialsSchema
+} from "./ssh-connection-schemas";
+
+export type TSshConnection = z.infer<typeof SshConnectionSchema>;
+
+export type TSshConnectionInput = z.infer<typeof CreateSshConnectionSchema> & {
+ app: AppConnection.SSH;
+};
+
+export type TValidateSshConnectionCredentialsSchema = typeof ValidateSshConnectionCredentialsSchema;
+
+export type TSshConnectionConfig = DiscriminativePick<
+ TSshConnectionInput,
+ "method" | "app" | "credentials" | "gatewayId"
+> & {
+ orgId: string;
+};