Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ public void updateKeyPairs() {
// FIXME: take a global database lock here for safety.
boolean onWindows = isOnWindows();
if(!onWindows) {
Script.runSimpleBashScript("if [ -f " + privkeyfile + " ]; then rm -f " + privkeyfile + "; fi; ssh-keygen -t ecdsa -m PEM -N '' -f " + privkeyfile + " -q 2>/dev/null || ssh-keygen -t ecdsa -N '' -f " + privkeyfile + " -q");
if (!privkeyfile.exists() && !pubkeyfile.exists()) {
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition !privkeyfile.exists() && !pubkeyfile.exists() uses AND logic, which will prevent SSH key generation if only one of the key files exists. This could leave the system in an inconsistent state. Consider using OR logic (||) instead, or check if BOTH files exist before skipping generation:

if (privkeyfile.exists() && pubkeyfile.exists()) {
    // Both keys exist, skip generation
} else {
    // At least one key is missing, regenerate both
    Script.runSimpleBashScript("if [ -f " + privkeyfile + " ]; then rm -f " + privkeyfile + "; fi; ssh-keygen -t ecdsa -m PEM -N '' -f " + privkeyfile + " -q 2>/dev/null || ssh-keygen -t ecdsa -N '' -f " + privkeyfile + " -q");
}

This ensures that both keys are always present and consistent when the code proceeds to read them at lines 628-638.

Suggested change
if (!privkeyfile.exists() && !pubkeyfile.exists()) {
if (!privkeyfile.exists() || !pubkeyfile.exists()) {

Copilot uses AI. Check for mistakes.
Script.runSimpleBashScript("if [ -f " + privkeyfile + " ]; then rm -f " + privkeyfile + "; fi; ssh-keygen -t ecdsa -m PEM -N '' -f " + privkeyfile + " -q 2>/dev/null || ssh-keygen -t ecdsa -N '' -f " + privkeyfile + " -q");
}
}

final String privateKey;
Expand Down
Loading