[plasma/ksshaskpass] /: Support ssh-keygen
Kai Uwe Broulik <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit dfd6be597da6ff048ed0aedf554b44c34c7d8a03 by Kai Uwe Broulik.
Committed on 17/08/2026 at 14:09.
Pushed by broulik into branch 'master'.
Support ssh-keygen
Adds prompts for:
* Passphrase for generating a new key (with and without path)
* Changing passphrase for existing key
* Confirm passphrase
BUG: 485418
M +12 -0 autotests/tst_prompt.cpp
M +30 -0 src/prompt.cpp
https://invent.kde.org/plasma/ksshaskpass/-/commit/dfd6be597da6ff048ed0aedf554b44c34c7d8a03
diff --git a/autotests/tst_prompt.cpp b/autotests/tst_prompt.cpp
index b7f3545..05e2558 100644
--- a/autotests/tst_prompt.cpp
+++ b/autotests/tst_prompt.cpp
@@ -72,6 +72,18 @@ void PromptTest::testPrompt_data()
<< QStringLiteral("Bad passphrase, try again for /home/test/.ssh/id_ed25519 (will confirm each use): ")
<< QStringLiteral("/home/test/.ssh/id_ed25519") << DisplayType::Password << true;
+ QTest::newRow("ssh-keygen-new") << PromptType::Entry << QStringLiteral("Enter passphrase (empty for no passphrase): ") << QString() << DisplayType::Password
+ << true;
+
+ QTest::newRow("ssh-keygen-new-with-path") << PromptType::Entry
+ << QStringLiteral("Enter passphrase for \"/home/konqi/.ssh/id_rsa\" (empty for no passphrase): ") << QString()
+ << DisplayType::Password << true;
+
+ QTest::newRow("ssh-keygen-edit") << PromptType::Entry << QStringLiteral("Enter new passphrase (empty for no passphrase): ") << QString()
+ << DisplayType::Password << true;
+
+ QTest::newRow("ssh-keygen-confirm") << PromptType::Entry << QStringLiteral("Enter same passphrase again: ") << QString() << DisplayType::Password << true;
+
// PGP PIN
QTest::newRow("pkcs11-pin") << PromptType::Entry << QStringLiteral("Enter PIN for 'OpenPGP': ") << QStringLiteral("OpenPGP") << DisplayType::Password
diff --git a/src/prompt.cpp b/src/prompt.cpp
index a3b890f..8c9d255 100644
--- a/src/prompt.cpp
+++ b/src/prompt.cpp
@@ -56,6 +56,36 @@ void parsePrompt(PromptType promptType, const QString &prompt, QString &identifi
return;
}
+ // openssh ssh-keygen.c
+ // Case: ssh-keygen asking for passphrase, newer ssh-keygen includes the path.
+ match = QRegularExpression(QStringLiteral("^Enter passphrase (for \"(.*?)\" )?\\(empty for no passphrase\\): $")).match(prompt);
+ if (match.hasMatch()) {
+ identifier = QString();
+ displayType = DisplayType::Password;
+ ignoreKeychain = true;
+ return;
+ }
+
+ // openssh ssh-keygen.c
+ // Case: ssh-keygen asking for passphrase when changing existing key
+ match = QRegularExpression(QStringLiteral("^Enter new passphrase \\(empty for no passphrase\\): $")).match(prompt);
+ if (match.hasMatch()) {
+ identifier = QString();
+ displayType = DisplayType::Password;
+ ignoreKeychain = true;
+ return;
+ }
+
+ // openssh ssh-keygen.c
+ // Case: ssh-keygen asking to confirm passphrase
+ match = QRegularExpression(QStringLiteral("^Enter same passphrase again: $")).match(prompt);
+ if (match.hasMatch()) {
+ identifier = QString();
+ displayType = DisplayType::Password;
+ ignoreKeychain = true;
+ return;
+ }
+
// openssh sshconnect2.c and sshconnect1.c
// Case: asking for passphrase for a certain keyfile
match = QRegularExpression(QStringLiteral("^Enter passphrase for( RSA)? key '(.*)': $")).match(prompt);