add option to use ssh agent for authentication

This commit is contained in:
Jelle Roets 2018-03-17 17:05:34 +01:00
commit 16370ea112
3 changed files with 19 additions and 1 deletions

View file

@ -162,6 +162,11 @@
"type": "string", "type": "string",
"description": "Absolute path to private key" "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": { "forwardX11": {
"type": "boolean", "type": "boolean",
"description": "If true, the server will redirect x11 to the local host", "description": "If true, the server will redirect x11 to the local host",
@ -287,6 +292,11 @@
"type": "string", "type": "string",
"description": "Absolute path to private key" "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": { "forwardX11": {
"type": "boolean", "type": "boolean",
"description": "If true, the server will redirect x11 to the local host", "description": "If true, the server will redirect x11 to the local host",
@ -547,6 +557,11 @@
"type": "string", "type": "string",
"description": "Absolute path to private key" "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": { "forwardX11": {
"type": "boolean", "type": "boolean",
"description": "If true, the server will redirect x11 to the local host", "description": "If true, the server will redirect x11 to the local host",

View file

@ -38,6 +38,7 @@ export interface SSHArguments {
host: string; host: string;
keyfile: string; keyfile: string;
password: string; password: string;
useAgent: boolean;
cwd: string; cwd: string;
port: number; port: number;
user: string; user: string;

View file

@ -121,7 +121,9 @@ export class MI2 extends EventEmitter implements IBackend {
username: args.user 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)) if (require("fs").existsSync(args.keyfile))
connectionArgs.privateKey = require("fs").readFileSync(args.keyfile); connectionArgs.privateKey = require("fs").readFileSync(args.keyfile);
else { else {