Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72450

Support alternate ssh implementations on Windows

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-client-plugin
    • None

      We are setting up a new Windows 2021 build node. This build node is connected from our Jenkins server using a ssh connection. This is done by using the "Microsoft OpenSSH Server 9.2.20".
      We are Running as scripted Pipeline with the following part:

      stage('checkout') {
      sh 'which ssh'
      bat 'where ssh'
      checkout([$class: 'GitSCM', branches: [[name: """$COMMIT"""]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'd7695a83-ac09-4660-8b95-74094f8059a5', url: GIT_URL]]])
      // set COMMIT_SHA1 variable with the checked out commit SHA1
      COMMIT_SHA1=sh script:'git rev-parse --verify HEAD', returnStdout: true
      }

      this results in the Error: "ssh executable not found."

      15:34:59 [Pipeline] stage
      15:34:59 [Pipeline] { (checkout)
      15:34:59 [Pipeline] sh
      15:35:00 + which ssh
      15:35:00 /c/Program Files/OpenSSH/ssh
      15:35:00 [Pipeline] bat
      15:35:00
      15:35:00 oaad\xentcon@GCDXENTCON31 F:\X.com-CIB>where ssh
      15:35:00 C:\Program Files\OpenSSH\ssh.exe
      15:35:00 [Pipeline] checkout
      15:35:00 The recommended git tool is: NONE
      15:35:00 using credential d7695a83-ac09-4660-8b95-74094f8059a5
      15:35:00 Fetching changes from the remote Git repository
      15:35:00 [Pipeline] }
      15:35:00 [Pipeline] // stage
      15:35:00 [Pipeline] echo
      15:35:00 catch2
      15:35:00 [Pipeline] echo
      15:35:00 java.lang.RuntimeException: ssh executable not found. The git plugin only supports official git client https://git-scm.com/download/win

      This pipeline is running without any problems with no change on an jnlp client Windows.

      For me it looks like the git-plugin expects to have an external ssh.exe in the path
      C:\Program Files\OpenSSH\ssh.exe
      which is definitely available. The PATH in the gitbash is:

      PATH=/cmd:/mingw64/bin:/usr/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/PowerShell/7:/c/Program Files/Google/Compute Engine/sysprep:/cmd:.:/c/JavaInPath/bin:/c/PerlInPath/bin:/c/PerlInPath/site/bin:/c/strawberry/c/bin:/c/CMUtils:/c/PythonInPath:/c/Users/xentcon/AppData/Local/Microsoft/WindowsApps

          [JENKINS-72450] Support alternate ssh implementations on Windows

          bros mar added a comment -

          I found the problematic source:
          https://github.com/jenkinsci/git-client-plugin/blob/af2300a904c9e0c53f70dac162f271f01ee9d56c/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L2691
          The current git-client-plugin is searching for specific ssh.exe iplementation. But the plugin is not aware of the fact that the new official windows git version 2.43 is also supporting external ssh.exe souloutions.

          bros mar added a comment - I found the problematic source: https://github.com/jenkinsci/git-client-plugin/blob/af2300a904c9e0c53f70dac162f271f01ee9d56c/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L2691 The current git-client-plugin is searching for specific ssh.exe iplementation. But the plugin is not aware of the fact that the new official windows git version 2.43 is also supporting external ssh.exe souloutions.

          Mark Waite added a comment -

          Thanks for the report. I think it is a reasonable enhancement request that the git client plugin on Windows should allow alternate ssh implementations, with the assumption that the user will be responsible for the compatibility of the alternate ssh implementation with git for Windows.

          I believe that the git client plugin originally limited the ssh implementations it would support so that it would avoid confusing command line git with any unrelated program that happened to be named ssh. Microsoft has supported an OpenSSH port to Windows that includes an ssh implementation that is usable with command line git. Since Microsoft supports OpenSSH on Windows 10, Windows 11, and Windows Server, it makes sense that the git client plugin should allow the Microsoft ssh implementation to be used with the git client plugin.

          In case you're looking for a workaround, the git client plugin documentation includes instructions to install MinGit for Windows. MinGit is well suited for use on Jenkins agents. It is smaller than command line git for Windows and avoids many of the more complicated configurations that can disrupt a Jenkins agent as it uses command line git.

          Mark Waite added a comment - Thanks for the report. I think it is a reasonable enhancement request that the git client plugin on Windows should allow alternate ssh implementations, with the assumption that the user will be responsible for the compatibility of the alternate ssh implementation with git for Windows. I believe that the git client plugin originally limited the ssh implementations it would support so that it would avoid confusing command line git with any unrelated program that happened to be named ssh. Microsoft has supported an OpenSSH port to Windows that includes an ssh implementation that is usable with command line git. Since Microsoft supports OpenSSH on Windows 10, Windows 11, and Windows Server, it makes sense that the git client plugin should allow the Microsoft ssh implementation to be used with the git client plugin. In case you're looking for a workaround, the git client plugin documentation includes instructions to install MinGit for Windows . MinGit is well suited for use on Jenkins agents. It is smaller than command line git for Windows and avoids many of the more complicated configurations that can disrupt a Jenkins agent as it uses command line git.

          bros mar added a comment - - edited

          markewaite Thank you for your update. I try to rely on the microsoft ssh implementation.

          I tried to set the environment variable GIT_SSH=C:\Program Files\OpenSSH\ssh.exe. But this sadly with no success. The error is exactly the same. I tried many variants of the possible forms:

          C:\Program Files\OpenSSH\ssh.exe
          "C:\Program Files\OpenSSH\ssh.exe"
          /c/Program\F iles\OpenSSH\ssh.exe
          /c/Program\F iles\OpenSSH\ssh
          c:\temp\ssh.exe (copied ssh.exe to this location)

          All with no success. Do you have an idea why this is no possible workaround as to be expected by:
          public File getSSHExecutable() {
          // First check the GIT_SSH environment variable
          File sshexe = getFileFromEnv("GIT_SSH", "");
          if (sshexe != null && sshexe.exists())

          { return sshexe; }

          PS: To enter code hier is quite complicated. Monospace dose not work wich { (curly brackets) in it
          {{
          if (true)

          { .... Problem }

          }}

          bros mar added a comment - - edited markewaite Thank you for your update. I try to rely on the microsoft ssh implementation. I tried to set the environment variable GIT_SSH=C:\Program Files\OpenSSH\ssh.exe. But this sadly with no success. The error is exactly the same. I tried many variants of the possible forms: C:\Program Files\OpenSSH\ssh.exe "C:\Program Files\OpenSSH\ssh.exe" /c/Program\F iles\OpenSSH\ssh.exe /c/Program\F iles\OpenSSH\ssh c:\temp\ssh.exe (copied ssh.exe to this location) All with no success. Do you have an idea why this is no possible workaround as to be expected by: public File getSSHExecutable() { // First check the GIT_SSH environment variable File sshexe = getFileFromEnv("GIT_SSH", ""); if (sshexe != null && sshexe.exists()) { return sshexe; } PS: To enter code hier is quite complicated. Monospace dose not work wich { (curly brackets) in it {{ if (true) { .... Problem } }}

          Mark Waite added a comment -

          I appreciate that you try to rely on the Microsoft implementation of OpenSSH. Unfortunately, the git client plugin does not test with the Microsoft implementation of OpenSSH. It tests with the OpenSSH implementation provided in Git for Windows by the Microsoft employee (Johannes Schindelin) that maintains Git for Windows. I'm offline for the holidays and am not likely to spend significant time on the git client plugin until after the end of the 2023 calendar year. I recommend MinGit for Windows and the ssh implementation included in MinGit for Windows.

          Mark Waite added a comment - I appreciate that you try to rely on the Microsoft implementation of OpenSSH. Unfortunately, the git client plugin does not test with the Microsoft implementation of OpenSSH. It tests with the OpenSSH implementation provided in Git for Windows by the Microsoft employee ( Johannes Schindelin ) that maintains Git for Windows. I'm offline for the holidays and am not likely to spend significant time on the git client plugin until after the end of the 2023 calendar year. I recommend MinGit for Windows and the ssh implementation included in MinGit for Windows.

          +1 on this. I was facing the same few month ago on Windows 10 nodes with OpenSSH but never took the time to look for issues for it.

          I don't remember my workaround (I think was switching to HTTPS urls)

          Valentin Delaye added a comment - +1 on this. I was facing the same few month ago on Windows 10 nodes with OpenSSH but never took the time to look for issues for it. I don't remember my workaround (I think was switching to HTTPS urls)

            markewaite Mark Waite
            brosmar bros mar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: