From c64692fa8a70835d0f9aa7fca80c4f044890dc8b Mon Sep 17 00:00:00 2001 From: Amedee Van Gasse Date: Tue, 13 Apr 2021 11:39:47 +0200 Subject: [PATCH] SSH key check is too strict Keys with BEGIN OPENSSH PRIVATE KEY are also valid Reported on mailing list: https://groups.google.com/g/jenkinsci-users/c/GwDegE_BdMg --- src/main/java/hudson/plugins/ec2/EC2Cloud.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/plugins/ec2/EC2Cloud.java b/src/main/java/hudson/plugins/ec2/EC2Cloud.java index be1e9f706..606f08c11 100644 --- a/src/main/java/hudson/plugins/ec2/EC2Cloud.java +++ b/src/main/java/hudson/plugins/ec2/EC2Cloud.java @@ -1102,9 +1102,11 @@ public FormValidation doCheckSshKeysCredentialsId(@QueryParameter String value) BufferedReader br = new BufferedReader(new StringReader(privateKey)); String line; while ((line = br.readLine()) != null) { - if (line.equals("-----BEGIN RSA PRIVATE KEY-----")) + if (line.equals("-----BEGIN RSA PRIVATE KEY-----") || + line.equals("-----BEGIN OPENSSH PRIVATE KEY-----")) hasStart = true; - if (line.equals("-----END RSA PRIVATE KEY-----")) + if (line.equals("-----END RSA PRIVATE KEY-----") || + line.equals("-----END OPENSSH PRIVATE KEY-----")) hasEnd = true; } if (!hasStart)