fix: solve the problem that the private key not works when connecting because permission of private key is too open
This commit is contained in:
@@ -122,8 +122,10 @@ export default class User {
|
|||||||
const privateKeyStr = privateKey;
|
const privateKeyStr = privateKey;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(this.getUserPublicKeyPath(), publicKeyStr);
|
await fs.writeFileSync(this.getUserPublicKeyPath(), publicKeyStr);
|
||||||
fs.writeFileSync(this.getUserPrivateKeyPath(), privateKeyStr);
|
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) {
|
} catch(error) {
|
||||||
console.error("Failed to write public/private key into the default ssh public/key file: ", error);
|
console.error("Failed to write public/private key into the default ssh public/key file: ", error);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user