[plasma/ksshaskpass] /: Handle unknown host when key is known for someone else
Kai Uwe Broulik <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b99b1a027b6b3a5e0704d17c6357e20de8e918d8 by Kai Uwe Broulik.
Committed on 17/08/2026 at 14:09.
Pushed by broulik into branch 'master'.
Handle unknown host when key is known for someone else
In addition to "This key is not known by any other names" also handle
"This host key is known by the following other names/addresses" by
making the rationale part of the regular expression generic.
M +9 -0 autotests/tst_prompt.cpp
M +1 -1 src/prompt.cpp
https://invent.kde.org/plasma/ksshaskpass/-/commit/b99b1a027b6b3a5e0704d17c6357e20de8e918d8
diff --git a/autotests/tst_prompt.cpp b/autotests/tst_prompt.cpp
index 05e2558..b14c8b3 100644
--- a/autotests/tst_prompt.cpp
+++ b/autotests/tst_prompt.cpp
@@ -129,6 +129,15 @@ void PromptTest::testPrompt_data()
"Are you sure you want to continue connecting (yes/no/[fingerprint])? ")
<< QString() << DisplayType::UnknownSshHost << true;
+ QTest::newRow("unknown-host-other-name") << PromptType::Entry
+ << QStringLiteral(
+ "The authenticity of host 'invent.kde.org (1.2.3.4)' can't be established.\n"
+ "ED25519 key fingerprint is SHA256:1234567890abcdef.\n"
+ "This host key is known by the following other names/addresses:\n"
+ " ~/.ssh/known_hosts:14: [hashed name]\n"
+ "Are you sure you want to continue connecting (yes/no/[fingerprint])? ")
+ << QString() << DisplayType::UnknownSshHost << true;
+
QTest::newRow("unknown-host-colon") << PromptType::Entry
<< QStringLiteral(
"The authenticity of host 'invent.kde.org (1.2.3.4)' can't be established.\n"
diff --git a/src/prompt.cpp b/src/prompt.cpp
index 8c9d255..b78e817 100644
--- a/src/prompt.cpp
+++ b/src/prompt.cpp
@@ -209,7 +209,7 @@ void parsePrompt(PromptType promptType, const QString &prompt, QString &identifi
// Case: unknown SSH host
match = QRegularExpression(QStringLiteral("^The authenticity of host '([^']+)(?: \\(([^)]+)\\))?' can't be established\\.\n"
"([A-Z0-9_-]+) key fingerprint is:? ([A-Za-z0-9:+/=]+)\\.\n"
- "This key is not known by any other names\\.\n"
+ "(?:.*\n)*"
"Are you sure you want to continue connecting \\(yes/no/\\[fingerprint\\]\\)\\?\\s*$"))
.match(prompt);
if (match.hasMatch()) {