diff --git a/package.json b/package.json index 82ae7d0..d194669 100644 --- a/package.json +++ b/package.json @@ -162,6 +162,11 @@ "type": "string", "description": "Absolute path to private key" }, + "useAgent": { + "type": "boolean", + "description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication", + "default": false + }, "forwardX11": { "type": "boolean", "description": "If true, the server will redirect x11 to the local host", @@ -287,6 +292,11 @@ "type": "string", "description": "Absolute path to private key" }, + "useAgent": { + "type": "boolean", + "description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication", + "default": false + }, "forwardX11": { "type": "boolean", "description": "If true, the server will redirect x11 to the local host", @@ -547,6 +557,11 @@ "type": "string", "description": "Absolute path to private key" }, + "useAgent": { + "type": "boolean", + "description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication", + "default": false + }, "forwardX11": { "type": "boolean", "description": "If true, the server will redirect x11 to the local host", diff --git a/src/backend/backend.ts b/src/backend/backend.ts index 2b124bc..1302808 100644 --- a/src/backend/backend.ts +++ b/src/backend/backend.ts @@ -38,6 +38,7 @@ export interface SSHArguments { host: string; keyfile: string; password: string; + useAgent: boolean; cwd: string; port: number; user: string; diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index 9049bcf..f6bec8d 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -121,7 +121,9 @@ export class MI2 extends EventEmitter implements IBackend { username: args.user }; - if (args.keyfile) { + if (args.useAgent) { + connectionArgs.agent = process.env.SSH_AUTH_SOCK; + } else if (args.keyfile) { if (require("fs").existsSync(args.keyfile)) connectionArgs.privateKey = require("fs").readFileSync(args.keyfile); else {