sftp: delete any existing keys since we are committed to regenerating at this point in code
This commit is contained in:
@@ -33,6 +33,8 @@ async function ensureKeys() {
|
||||
|
||||
if (!privateKey || !publicKey) {
|
||||
debug(`ensureSecrets: generating new sftp keys of type ${keyType}`);
|
||||
safe.fs.unlinkSync(publicKeyFile);
|
||||
safe.fs.unlinkSync(privateKeyFile);
|
||||
if (!safe.child_process.execSync(`ssh-keygen -m PEM -t ${keyType} -f "${paths.SFTP_KEYS_DIR}/ssh_host_${keyType}_key" -q -N ""`)) throw new BoxError(BoxError.OPENSSL_ERROR, `Could not generate sftp ${keyType} keys: ${safe.error.message}`);
|
||||
const newPublicKey = safe.fs.readFileSync(publicKeyFile);
|
||||
await blobs.set(`sftp_${keyType}_public_key`, newPublicKey);
|
||||
|
||||
Reference in New Issue
Block a user