mirror of
https://github.com/community-scripts/ProxmoxVE-Local.git
synced 2026-08-04 19:25:11 -04:00
fix: generate key pair hangs when key files already exist (#590)
ssh-keygen prompts 'Overwrite (y/n)?' on stdout when the target file exists. With stdio: ['pipe','pipe','pipe'] nothing is written to stdin, so the process blocks indefinitely. Delete both the private key and its .pub counterpart before spawning ssh-keygen so the overwrite prompt is never triggered.
This commit is contained in:
@@ -662,7 +662,14 @@ expect {
|
||||
async generateKeyPair(serverId) {
|
||||
const sshKeysDir = join(process.cwd(), 'data', 'ssh-keys');
|
||||
const keyPath = join(sshKeysDir, `server_${serverId}_key`);
|
||||
|
||||
const keyPubPath = keyPath + '.pub';
|
||||
|
||||
// Remove existing key files so ssh-keygen does not prompt "Overwrite (y/n)?"
|
||||
// which would block stdin indefinitely.
|
||||
for (const p of [keyPath, keyPubPath]) {
|
||||
try { unlinkSync(p); } catch { /* file didn't exist – that's fine */ }
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const sshKeygen = spawn('ssh-keygen', [
|
||||
'-t', 'ed25519',
|
||||
|
||||
Reference in New Issue
Block a user