Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jan 3, 2018
1 parent b973ca3 commit 5dc6fed
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/clients/sftp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ export async function openConnection(opts: SFTPConnectionOptions): Promise<SFTPC
pwd = undefined;
}

let privateKeyFile: string = deploy_helpers.toStringSafe(opts.privateKey);
let privateKeyFile: string | false = deploy_helpers.toStringSafe(opts.privateKey);
if (deploy_helpers.isEmptyString(privateKeyFile)) {
privateKeyFile = undefined;
privateKeyFile = false;
}

let privateKeyPassphrase = deploy_helpers.toStringSafe(opts.privateKeyPassphrase);
Expand All @@ -400,6 +400,11 @@ export async function openConnection(opts: SFTPConnectionOptions): Promise<SFTPC
readyTimeout = 20000;
}

let privateKey: Buffer;
if (false !== privateKeyFile) {
privateKey = await deploy_helpers.readFile(privateKeyFile);
}

const DEBUG = deploy_helpers.toBooleanSafe(opts.debug);

await CLIENT.client.connect({
Expand All @@ -418,7 +423,7 @@ export async function openConnection(opts: SFTPConnectionOptions): Promise<SFTPC
passphrase: privateKeyPassphrase,
password: pwd,
port: port,
privateKey: FS.readFileSync(privateKeyFile, {'encoding':'utf8'}),
privateKey: privateKey,
readyTimeout: readyTimeout,
tryKeyboard: deploy_helpers.toBooleanSafe(opts.tryKeyboard),
username: user,
Expand Down

0 comments on commit 5dc6fed

Please sign in to comment.