252
}
253
255
>
const text = key.toString('utf8');
256
>
if (/-----BEGIN ENCRYPTED PRIVATE KEY-----/.test(text) || /Proc-Type:\s*4,ENCRYPTED/i.test(text)) {
257
return true;
258
}
259
>
const openSSHKey = /-----BEGIN OPENSSH PRIVATE KEY-----([\s\S]+?)-----END OPENSSH PRIVATE KEY-----/.exec(text);
sshRemoteAgentHostService.ts
260
>
if (!openSSHKey) {
261
return false;
262
}
263
const data = Buffer.from(openSSHKey[1].replace(/\s+/g, ''), 'base64');
264
const magic = Buffer.from('openssh-key-v1\0', 'utf8');
266
return false;
267
}
268
const cipher = readSSHString(data, magic.length);
269
return !!cipher && cipher.value !== 'none';
271
272
function sshExec(client: SSHClient, command: string, opts?: { ignoreExitCode?: boolean }): Promise<{ stdout: string; stderr: string; code: number }> {