diff --git a/src/user.ts b/src/user.ts index 905b1c9..25da344 100644 --- a/src/user.ts +++ b/src/user.ts @@ -122,8 +122,10 @@ export default class User { const privateKeyStr = privateKey; try { - fs.writeFileSync(this.getUserPublicKeyPath(), publicKeyStr); - fs.writeFileSync(this.getUserPrivateKeyPath(), privateKeyStr); + await fs.writeFileSync(this.getUserPublicKeyPath(), publicKeyStr); + await fs.writeFileSync(this.getUserPrivateKeyPath(), privateKeyStr); + // limit the permission of private key to prevent that the private key not works + await fs.chmodSync(this.getUserPrivateKeyPath(), 0o600) } catch(error) { console.error("Failed to write public/private key into the default ssh public/key file: ", error); }