Skip to content

Commit bbac975

Browse files
committed
Optional passthrase when using SSH key in UI
Fixes #472
1 parent 91b7927 commit bbac975

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/typings.ts

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface ConnectionData {
7474
username: string;
7575
password?: string;
7676
privateKey: string | null;
77+
passphrase?: string;
7778
keepaliveInterval?: number;
7879
}
7980

src/webviews/login/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export class Login {
2727
.addParagraph(`Only provide either the password or a private key - not both.`)
2828
.addPassword(`password`, `Password`)
2929
.addCheckbox(`savePassword`, `Save Password`)
30+
.addHorizontalRule()
3031
.addFile(`privateKey`, `Private Key`, `OpenSSH, RFC4716, or PPK formats are supported.`)
32+
.addInput(`passphrase`, `Private key passphrase`)
3133
.addButtons(
3234
{ id: `connect`, label: `Connect`, requiresValidation: true },
3335
{ id: `saveExit`, label: `Save & Exit` }
@@ -54,7 +56,8 @@ export class Login {
5456
host: data.host,
5557
port: data.port,
5658
username: data.username,
57-
privateKey: data.privateKey
59+
privateKey: data.privateKey,
60+
passphrase: data.passphrase.length > 0 ? data.passphrase : undefined
5861
});
5962

6063
if (data.savePassword) context.secrets.store(`${data.name}_password`, `${data.password}`);

src/webviews/settings/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ export class SettingsUI {
227227
.addInput(`username`, `Username`, undefined, { default: connection.username, minlength: 1 })
228228
.addParagraph(`Only provide either the password or a private key - not both.`)
229229
.addPassword(`password`, `Password`, `Only provide a password if you want to update an existing one or set a new one.`)
230+
.addHorizontalRule()
230231
.addFile(`privateKey`, `Private Key${connection.privateKey ? ` (current: ${connection.privateKey})` : ``}`, `Only provide a private key if you want to update from the existing one or set one. OpenSSH, RFC4716, or PPK formats are supported.`)
232+
.addInput(`passphrase`, `Private key passphrase`, undefined, {default: connection.passphrase})
231233
.addButtons({ id: `submitButton`, label: `Save`, requiresValidation: true })
232234
.loadPage<any>(`Login Settings: ${name}`);
233235

@@ -246,6 +248,8 @@ export class SettingsUI {
246248

247249
delete data.password;
248250

251+
data.passphrase = data.passphrase.length > 0 ? data.passphrase : undefined;
252+
249253
connection = {
250254
...connection,
251255
...data

0 commit comments

Comments
 (0)