Skip to content

Commit 0ce3339

Browse files
authored
Merge pull request #136 from JelleRoets/master
add option to use ssh agent for authentication
2 parents bcbbda1 + 16370ea commit 0ce3339

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
"type": "string",
163163
"description": "Absolute path to private key"
164164
},
165+
"useAgent": {
166+
"type": "boolean",
167+
"description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication",
168+
"default": false
169+
},
165170
"forwardX11": {
166171
"type": "boolean",
167172
"description": "If true, the server will redirect x11 to the local host",
@@ -287,6 +292,11 @@
287292
"type": "string",
288293
"description": "Absolute path to private key"
289294
},
295+
"useAgent": {
296+
"type": "boolean",
297+
"description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication",
298+
"default": false
299+
},
290300
"forwardX11": {
291301
"type": "boolean",
292302
"description": "If true, the server will redirect x11 to the local host",
@@ -547,6 +557,11 @@
547557
"type": "string",
548558
"description": "Absolute path to private key"
549559
},
560+
"useAgent": {
561+
"type": "boolean",
562+
"description": "Auto-detect the running SSH agent (via SSH_AUTH_SOCK environment variable) and use it to perform authentication",
563+
"default": false
564+
},
550565
"forwardX11": {
551566
"type": "boolean",
552567
"description": "If true, the server will redirect x11 to the local host",

src/backend/backend.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface SSHArguments {
3838
host: string;
3939
keyfile: string;
4040
password: string;
41+
useAgent: boolean;
4142
cwd: string;
4243
port: number;
4344
user: string;

src/backend/mi2/mi2.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ export class MI2 extends EventEmitter implements IBackend {
121121
username: args.user
122122
};
123123

124-
if (args.keyfile) {
124+
if (args.useAgent) {
125+
connectionArgs.agent = process.env.SSH_AUTH_SOCK;
126+
} else if (args.keyfile) {
125127
if (require("fs").existsSync(args.keyfile))
126128
connectionArgs.privateKey = require("fs").readFileSync(args.keyfile);
127129
else {

0 commit comments

Comments
 (0)