diff --git a/lib/utils/sshCopyFile.js b/lib/utils/sshCopyFile.js index 3dec15e..27b801a 100644 --- a/lib/utils/sshCopyFile.js +++ b/lib/utils/sshCopyFile.js @@ -52,8 +52,15 @@ export async function sshCopyFile(connection, source, destination, options) { }); writeStream.on('close', () => { - resolve(`Uploaded: ${sourceFile} -> ${destinationFile}`); - sftp.end(); + const sourceFileMode = fs.statSync(sourceFile).mode; + sftp.chmod(destinationFile, sourceFileMode, (err) => { + sftp.end(); + if (err) { + reject(`Error setting file permissions: ${err.message}`); + } else { + resolve(`Uploaded: ${sourceFile} -> ${destinationFile}`); + } + }); }); readStream.pipe(writeStream);