Merge pull request #136 from JelleRoets/master

add option to use ssh agent for authentication
This commit is contained in:
Jan Jurzitza 2018-03-17 20:55:28 +01:00 committed by GitHub
commit 0ce3339be9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View file

@ -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",

View file

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

View file

@ -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 {