-
Notifications
You must be signed in to change notification settings - Fork 707
[JENKINS-76058] Fix OpenSSH Certificate Hostkey handling + Improve verifier #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c9cc4e
[JENKINS-76058] Add verifier test including OpenSSH Certificate
Dohbedoh f486f9e
[JENKINS-76058] Fix OpenSSH Certificate Hostkey handling + Improve ve…
Dohbedoh d3dfff0
[JENKINS-76058] Fix documentation
Dohbedoh 1ae9cf0
[JENKINS-76058] Use Locale.ROOT
Dohbedoh b903597
[JENKINS-76058] Add warning if cannot compute fingerprint
Dohbedoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/hudson/plugins/ec2/ssh/EC2SSHLauncherTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package hudson.plugins.ec2.ssh; | ||
|
|
||
| import hudson.model.TaskListener; | ||
| import hudson.plugins.ec2.HostKeyVerificationStrategyEnum; | ||
| import hudson.plugins.ec2.MockEC2Computer; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
| import org.apache.sshd.common.config.keys.PublicKeyEntry; | ||
| import org.junit.Assert; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.jvnet.hudson.test.JenkinsRule; | ||
|
|
||
| public class EC2SSHLauncherTest { | ||
|
|
||
| @Rule | ||
| public JenkinsRule r = new JenkinsRule(); | ||
|
|
||
| @Test | ||
| public void testServerKeyVerifier() throws Exception { | ||
| for (String publicKeyFile : List.of( | ||
| "ssh_host_dss_1024.pub", | ||
| "ssh_host_rsa_1024.pub", | ||
| "ssh_host_rsa_2048.pub", | ||
| "ssh_host_rsa_3072.pub", | ||
| "ssh_host_rsa_4096.pub", | ||
| // Special case of Open SSH Certificate | ||
| // ssh-keygen -t rsa -b 2048 -f ./ssh_host_rsa -N "" | ||
| // ssh-keygen -s ./ssh_host_rsa -I ec2SshLauncherTest -h -n localhost -V +0s:+999999999s | ||
| // ./ssh_host_rsa.pub | ||
| "ssh_host_rsa-cert.pub")) { | ||
|
|
||
| String sshHostKeyPath = Files.readString(Path.of(getClass() | ||
| .getClassLoader() | ||
| .getResource("hudson/plugins/ec2/ssh/" + publicKeyFile) | ||
| .getPath())) | ||
| .trim(); | ||
|
|
||
| MockEC2Computer computer = MockEC2Computer.createComputer(publicKeyFile); | ||
| r.jenkins.addNode(computer.getNode()); | ||
|
|
||
| computer.getSlaveTemplate().setHostKeyVerificationStrategy(HostKeyVerificationStrategyEnum.OFF); | ||
| Assert.assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL) | ||
| .verifyServerKey( | ||
| null, | ||
| null, | ||
| PublicKeyEntry.parsePublicKeyEntry(sshHostKeyPath).resolvePublicKey(null, null, null))); | ||
| computer.getSlaveTemplate().setHostKeyVerificationStrategy(HostKeyVerificationStrategyEnum.ACCEPT_NEW); | ||
| Assert.assertTrue(new EC2SSHLauncher.ServerKeyVerifierImpl(computer, TaskListener.NULL) | ||
| .verifyServerKey( | ||
| null, | ||
| null, | ||
| PublicKeyEntry.parsePublicKeyEntry(sshHostKeyPath).resolvePublicKey(null, null, null))); | ||
|
|
||
| r.jenkins.removeNode(computer.getNode()); | ||
| } | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_dss_1024.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-dss AAAAB3NzaC1kc3MAAACBAMsQrriFgun2KVgmsGd8drsplZLXyU8uU6r90aIZ+evRpxvoLCJf317Wnu5qVBCzGgEZ8iygYB0bDB/JFch+UVgtyXGH358ClJCDDgNWdOSogTl2gCF+W+8KoRSF+i3ObnEPOTa2akByP5FDzOO+mruVPl8kg8NHYcadCtJizRjhAAAAFQCV9uGT1Mchfbm6uFxEmZf09DwjSQAAAIAyyLw64QIHel17rzdyMyvepkvW4q64WYb7xCVLffaYJA8x1pxHtH4Mmmm0fGG7GFgdnCeD95524CYZR7TDhzKFGcEX607qKg0v5sXs6z8U8lGOeARq/IXQphb7YPZ9PdKUIuJImQEXriI0p5G7aGMmSYjnyEpKhUsM12xpDb2qBAAAAIBbIZPuZzBbbeesmzmGoG63w0tFc+tpPV3lNkAeYYcWpVhpSdHGFatr1lU+8LNT6OXekV2CFyF5kuuYw/B3OFkmHasURnT1+yC49OEpSzA3KOtQzqO2BZqIxDG/IEajKtSPGOWWPaVrHdgDXo3EZ6yCJtCiOMxW5Xz3fiUufp1sdQ== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| -----BEGIN OPENSSH PRIVATE KEY----- | ||
| b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn | ||
| NhAAAAAwEAAQAAAQEA1qUcUNNcGnZTvneThb9U4nqQdQ0EGc9cJv+W9lUhF7ph2jy2DeYs | ||
| HakQHX/nH5CgBFyvUlD7QGAqPC3/65X3h4QWSGH1kEWMq93F9cm33v0b31YPc/qbnw2Ns9 | ||
| M5yxIz7kd0a5Li0OkUi7ENhgm+jpmYwGw1VE+lMDxUqtpgAYMEcrESzfORR80W/9+iS8PU | ||
| peqdbVSWltD+Ze0TeY8UYWtiCqBUnkQ6nqp02Zrfzw4jcQCYRUvWT09b9AfU7nxzUAGGdS | ||
| fzdoNicus5QuLO3HIeLfvXM1Ln2KVGuylys1TVcLboc9srL6VNm/Vrc/wYGnQEkKz6G/NR | ||
| 2NbjZNz79wAAA9i8l634vJet+AAAAAdzc2gtcnNhAAABAQDWpRxQ01wadlO+d5OFv1Tiep | ||
| B1DQQZz1wm/5b2VSEXumHaPLYN5iwdqRAdf+cfkKAEXK9SUPtAYCo8Lf/rlfeHhBZIYfWQ | ||
| RYyr3cX1ybfe/RvfVg9z+pufDY2z0znLEjPuR3RrkuLQ6RSLsQ2GCb6OmZjAbDVUT6UwPF | ||
| Sq2mABgwRysRLN85FHzRb/36JLw9Sl6p1tVJaW0P5l7RN5jxRha2IKoFSeRDqeqnTZmt/P | ||
| DiNxAJhFS9ZPT1v0B9TufHNQAYZ1J/N2g2Jy6zlC4s7cch4t+9czUufYpUa7KXKz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||
| -----END OPENSSH PRIVATE KEY----- |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_rsa-cert.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [email protected] AAAAHHNzaC1yc2EtY2VydC12MDFAb3BlbnNzaC5jb20AAAAgdf6SSoXZeQwvZdumu/h7cd5umrlltC4dhhIWCLMGfy0AAAADAQABAAABAQDWpRxQ01wadlO+d5OFv1TiepB1DQQZz1wm/5b2VSEXumHaPLYN5iwdqRAdf+cfkKAEXK9SUPtAYCo8Lf/rlfeHhBZIYfWQRYyr3cX1ybfe/RvfVg9z+pufDY2z0znLEjPuR3RrkuLQ6RSLsQ2GCb6OmZjAbDVUT6UwPFSq2mABgwRysRLN85FHzRb/36JLw9Sl6p1tVJaW0P5l7RN5jxRha2IKoFSeRDqeqnTZmt/PDiNxAJhFS9ZPT1v0B9TufHNQAYZ1J/N2g2Jy6zlC4s7cch4t+9czUufYpUa7KXKzVNVwtuhz2ysvpU2b9Wtz/BgadASQrPob81HY1uNk3Pv3AAAAAAAAAAAAAAACAAAAEmVjMlNzaExhdW5jaGVyVGVzdAAAAA0AAAAJbG9jYWxob3N0AAAAAGi4HYoAAAAApFLniQAAAAAAAAAAAAAAAAAAARcAAAAHc3NoLXJzYQAAAAMBAAEAAAEBANalHFDTXBp2U753k4W/VOJ6kHUNBBnPXCb/lvZVIRe6Ydo8tg3mLB2pEB1/5x+QoARcr1JQ+0BgKjwt/+uV94eEFkhh9ZBFjKvdxfXJt979G99WD3P6m58NjbPTOcsSM+5HdGuS4tDpFIuxDYYJvo6ZmMBsNVRPpTA8VKraYAGDBHKxEs3zkUfNFv/fokvD1KXqnW1UlpbQ/mXtE3mPFGFrYgqgVJ5EOp6qdNma388OI3EAmEVL1k9PW/QH1O58c1ABhnUn83aDYnLrOULiztxyHi371zNS59ilRrspcrNU1XC26HPbKy+lTZv1a3P8GBp0BJCs+hvzUdjW42Tc+/cAAAEUAAAADHJzYS1zaGEyLTUxMgAAAQBDgCn5bPxMkYlpNK4EML4kxP2BxiHeMYze3RwpMpIzlbd3nLY8FP5kbdVa/OjQmyxonkus3eyOVePaOZE2Vir4wAxxF9EvTQshaPJ/MXkUPhIFfA1wocgxwNldrS/phrvGMqB18Y6dnw6hxMwsSl5hBEPFiDw3FY6X5o1LnUSrfHy4Ax5HBYouDKCgd6EQ8DYakPzvjunMSoD6rAFPYHpOCFkbXJjcLlnB5/ec38g8mJp43w4hdyf2Vg8Lh594tfD9fLvUxuCgZ6lqDGouetVHGNAKHTpEdbb6DZLk9gmyx8PbrX2uSY+Hm+vDhk6c05KPtsI5bc1o1wNax8Wh/6ru publickeycert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWpRxQ01wadlO+d5OFv1TiepB1DQQZz1wm/5b2VSEXumHaPLYN5iwdqRAdf+cfkKAEXK9SUPtAYCo8Lf/rlfeHhBZIYfWQRYyr3cX1ybfe/RvfVg9z+pufDY2z0znLEjPuR3RrkuLQ6RSLsQ2GCb6OmZjAbDVUT6UwPFSq2mABgwRysRLN85FHzRb/36JLw9Sl6p1tVJaW0P5l7RN5jxRha2IKoFSeRDqeqnTZmt/PDiNxAJhFS9ZPT1v0B9TufHNQAYZ1J/N2g2Jy6zlC4s7cch4t+9czUufYpUa7KXKzVNVwtuhz2ysvpU2b9Wtz/BgadASQrPob81HY1uNk3Pv3 publickey |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_rsa_1024.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC8nIRjuQr9gGfGTdq7BL4l3s4n4qEe3w7imhv1cT5cy2HT7DXvnA2gGVmFn4izbWlFlQG1lrtMgIiiwXH/shRx+2FnqayNsOmRJ37TiA0ICjkOrdR4JaYWRafQ0TEC0+EdHl+3iJYOhw9scFpJ2M9kB6W5HJsf4gmXoGGz8SsfsQ== |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_rsa_2048.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjw8Wgl1usvj9LCzF1c8PufEIG11V2PHCDNlYc66ccIiojQX79st1Lbp0BJXsa2bvZLYjfqyYP5gqkX7jLslmXPN+Vew91sRTmXJTlANlm/fChHg+Fq+lQK0IKGBIn9RlPDFH+NNoUIw4LbZ4etRJuOfMwiVKsOVOYuuLjiIJTkda9eS9zrhTRUXhUuMIxBLdeJEAYve6oBpcnTKpUbTV+DYlru3Yh6lSIevhA361s65oJauNHFQLQ7Ysi9apiF5hmqt1sThv/NPM/xLwlPrSGqKZWnclJbBKaWFlCijuM7W3Q5zbcdmtvKhxEJMobu+KMbt/LVhV7kD3BBLhADKnZ |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_rsa_3072.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDzvqmjwxE3UgKOVZDoji9npAu7Uee47sdS60cTN0yx3Aj+c5IznoBLDYt7HwUcjKoj6soRJALFMGvrKe6n4H1+9jF5vrstMB40Ga8858wweehIAEzw/ONAORZdHA2y0WG8K3+bNOVSeXZwASsjbKrYcdotsZarhQtGVks6xQwd7qXUD44DDdFuWsuj5//hSSYSIgjJE3gAfeI2qVoe6Cl6gTGoK9zd+hNrYDehpN7bDgX45ulcaMw7N2kLf+Sg5QqOYL3Xdav/SeNEefNUyE058uRK8Br3WhZh5BJ2qFjzUYe20cFKHJ3gqKiY+8aor6YrDAS5AOEAEdCw1GWHJutGeApouTSqpNZf1uHspKEgLCUu6gb+i14k3YGSqUW/3fRdqmtN5qBYGvOoqgUEG1wlsxjf6lvJxSh6551MEiM3dpXBq3wniFjK56pj9nVjW0erJsOXPIqh9KeQL1dB+fzNX0r3oAog3EEl+x+V/YLE12b8MR9qnaZwyxWPGKoRE70= |
1 change: 1 addition & 0 deletions
1
src/test/resources/hudson/plugins/ec2/ssh/ssh_host_rsa_4096.pub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCvoE/zGFhSYP/aXLGYl27P+Bq5KJ0E53Er163GJRZ119kgPTB17JOKEG1k25tmspoNYVVaSIM81zBi4RUIrP7ft+1wj2FlsMchrEHlrqR31HCCsPmf/YGgzaBBgL2KDNHEsnxIzyZTsY4ZGPS4LZMP8McUXfwvOFkVs12AUNH5hrB0SgMv6sor1VyW43p6u1o1w9MX5omANopOv+Rqm7In0UXNmOocOhOFYqDJVKt05+fI+fduHIwO4Wi3e0K1jK1EmC9YlIJJIz0Ce1+CyGK0Cm7lHj+W2Ea5tERO0DsK/etGbn1w8NcW9XmPVzO4vSvsMm7XrL0hIdNQZKSxas4NNwxr0TZN70T+H3WKRK9VAxCEp5IdahsSevKyrcsRnKX3mcemqJZZ+ODAarPdHemNacywzoaEt2AOSOl1PcW/sA49R4yMYHj8RS6xDv9jeA4Vogj58ynqzaB2F4fCkaV4bmgb2vL0Fkw96Tvq0+Gs902zvtDmnneicCWhNnj+3jRKZjqiQRvA3/BgYrokFGcDra4j9C1vrDVajMitcY+dr0XeA+n9ot29GSx36Fwg3j3QUhamS6/nsKTeIdmEHeym7FT6LKweKL/XcUCs+tkaJFxsJ+S1E+vF2M7SmqkNuB0S17EijZtw01v1zbzocscnfpLXo3UEfBdIe7pjT/IGtw== |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be
serverKey.getAlgorithm()butsshAlgorithm. This is causing an issue https://issues.jenkins.io/browse/JENKINS-76077