Skip to content
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

[JENKINS-64520][JENKINS-62340] Pass ssh host key to ssh process when using the strategy CHECK_NEW_HARD #590

Merged
merged 2 commits into from
Apr 16, 2021

Conversation

nigelarmstrong-bc
Copy link
Contributor

Pass ssh host key to ssh process when using the strategy CHECK_NEW_HARD. Without this when connecting via ssh process, the ssh process might not have the ssh host key. Take the ssh host key that jenkins already verified and pass that to the ssh process.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link
Contributor

@res0nance res0nance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok untested

knownHost = String.format("%s %s %s", ec2HostAddress, ec2HostKey.getAlgorithm(), Base64.getEncoder().encodeToString(ec2HostKey.getKey()));

try {
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit will probably just read better in a try with resources way
try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8))

which will take care of closing it on an exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given this a shot. My java isn't great, so would appreciate a double check of my changes.

@res0nance res0nance added the enhancement Feature additions or enhancements label Apr 13, 2021
@nigelarmstrong-bc
Copy link
Contributor Author

I tested this on our installation with CHECK_NEW_HARD and CHECK_NEW_SOFT, but I think it would be good to get more testing on other configurations.

@res0nance res0nance merged commit 99e930c into jenkinsci:master Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature additions or enhancements
Projects
None yet
2 participants