Skip to content

Use system temporary directory for known_hosts file#1709

Merged
MarkEWaite merged 1 commit intojenkinsci:stable-6.4from
MarkEWaite:use-system-temp-dir-for-known_hosts
Dec 16, 2025
Merged

Use system temporary directory for known_hosts file#1709
MarkEWaite merged 1 commit intojenkinsci:stable-6.4from
MarkEWaite:use-system-temp-dir-for-known_hosts

Conversation

@MarkEWaite
Copy link
Copy Markdown
Contributor

Use system temporary directory for known_hosts file

Windows ssh.exe 9.5p1 and ssh.exe 9.5p2 will not read the known_hosts file if there is a space character in the path to the file.

Since we already use the system temporary directory for other scripts that do not contain sensitive information, we'll use it for the known_hosts file as well. The contents of the known_hosts file is not sensitive information.

Fixes #1703

Amends 5a271e5

Testing done

  • Confirmed that without this change, Windows ssh.exe does not read the known_hosts file when using a manually verified known_hosts file from a workspace that has spaces in its absolute path.
  • Confirmed that with this change, Windows ssh.exe reads the known_hosts file when using a manually verified known_hosts file from a workspace that has spaces in its absolute path.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main 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 demonstrate the feature works or the issue is fixed

Windows ssh.exe 9.5p1 and ssh.exe 9.5p2 will not read the known_hosts
file if there is a space character in the path to the file.

Since we already use the system temporary directory for other scripts that
do not contain sensitive information, we'll use it for the known_hosts
file as well.  The contents of the known_hosts file is not sensitive
information.

Testing done:

* Confirmed that without this change, Windows ssh.exe does not read the
  known_hosts file when using a manually verified known_hosts file from
  a workspace that has spaces in its absolute path.

* Confirmed that with this change, Windows ssh.exe reads the known_hosts
  file when using a manually verified known_hosts file from a workspace
  that has spaces in its absolute path.

Fixes jenkinsci#1703
@MarkEWaite MarkEWaite requested a review from a team as a code owner December 16, 2025 04:25
@MarkEWaite MarkEWaite added the bug Incorrect or flawed behavior label Dec 16, 2025
@MarkEWaite
Copy link
Copy Markdown
Contributor Author

@mikecirioli I plan to release this as soon as it passes the CI checks. I'd like you to review the change, even if your review happens after the release.

I'll need to think more about techniques that might be used to include an automated test for this case.

@MarkEWaite
Copy link
Copy Markdown
Contributor Author

I'll need to think more about techniques that might be used to include an automated test for this case.

The simplest tests for that code would be to use real ssh credentials by cloning from a local repository over ssh. However, that requires more setup than I'm ready to do with the time available currently. I am accepting that this change does not have an automated test.

@MarkEWaite MarkEWaite merged commit 03ccd49 into jenkinsci:stable-6.4 Dec 16, 2025
18 checks passed
@MarkEWaite MarkEWaite deleted the use-system-temp-dir-for-known_hosts branch December 16, 2025 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Incorrect or flawed behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error cloning with ssh when manually verifying host key and workspace has a space character

1 participant