From 571dbe3cc1f7f7b5cfb243759ba065e44d5cc30a Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 29 Dec 2024 21:35:07 +0100 Subject: [PATCH] added support for PPK format private keys --- Cargo.toml | 3 ++- russh-keys/src/format/mod.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 22c345c7..977baa30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ sha1 = { version = "0.10.5", features = ["oid"] } sha2 = { version = "0.10.6", features = ["oid"] } signature = "2.2" ssh-encoding = { version = "0.2", features = ["bytes"] } -ssh-key = { version = "0.6.3-internal.2", features = [ +ssh-key = { version = "0.6.7-internal.4", features = [ "ed25519", "rsa", "rsa-sha1", @@ -36,6 +36,7 @@ ssh-key = { version = "0.6.3-internal.2", features = [ "p521", "encryption", ], package = "internal-russh-forked-ssh-key" } + "ppk", thiserror = "1.0.30" tokio = { version = "1.17.0" } tokio-stream = { version = "0.1.3", features = ["net", "sync"] } diff --git a/russh-keys/src/format/mod.rs b/russh-keys/src/format/mod.rs index cc56f794..8bd12b6a 100644 --- a/russh-keys/src/format/mod.rs +++ b/russh-keys/src/format/mod.rs @@ -44,6 +44,9 @@ enum Format { /// Decode a secret key, possibly deciphering it with the supplied /// password. pub fn decode_secret_key(secret: &str, password: Option<&str>) -> Result { + if secret.trim().starts_with("PuTTY-User-Key-File-") { + return Ok(PrivateKey::from_ppk(secret, password.map(Into::into))?); + } let mut format = None; let secret = { let mut started = false;