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

which ssh client to use on windows

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: ssh-agent-plugin
    • Labels:
    • Environment:
      windows server 2012, tcnative 1.2, jenkins 2.7.2, jdk 1.8.111
    • Similar Issues:

      Description

      When I have managed to get my credentials by ssh-agent I still don't know which ssh client command I am supposed to use then. mysysgit and putty's plink don't seem to profit from the agent.

      I managed to "install" the native library by adding the path to the dll to the path and then restart Jenkins.

      Then it always crashed if my credentials were not in putty's ppk format. Still I cannot execute a plink command. I'm not really sure why. I'd assumed because ppk was the only valid format for me, that I would have to use putty's commands.

      Before I had tried mysysgit's ssh command which doesn't seem to have the correct passphrase either.

      This job is successful, but the command is not really executed, as if the passphrase is still necessary and just not entered. If I enter the same command in cmd and enter the passphrase the command is actually executed.

      Here's my output:
      Started by user Admin
      Building in workspace D:\jenkins\workspace\freestyletest
      [ssh-agent] Looking for ssh-agent implementation...
      [ssh-agent] Java/tomcat-native ssh-agent
      [ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
      [ssh-agent] Started.
      [ssh-agent] Using credentials test-ppk
      [freestyletest] $ cmd /c call C:\Users\tcbld1\AppData\Local\Temp\2\hudson7374457953271842666.bat
      CLINK D:\jenkins\workspace\freestyletest>E:\putty\plink.exe -i C:\Users\tcbld1\.ssh\converted_for_putty_jenkins_id_rsa.ppk target-machine -l testuser touch plink
      Passphrase for key "imported-openssh-key":
      CLINK D:\jenkins\workspace\freestyletest>exit 0
      [ssh-agent] Stopped.
      Finished: SUCCESS

        Attachments

          Activity

          Hide
          kossmoboleat Tim Benke added a comment -

          If I understand the implementation correctly it starts an ssh agent, that any shell or batch script could use then.

          When I compare this with the usual Linux commands, I guess the ssh commands needs the environment variables to connect to the authentication socket and the agent's pid? How do I obtain these?

          Show
          kossmoboleat Tim Benke added a comment - If I understand the implementation correctly it starts an ssh agent, that any shell or batch script could use then. When I compare this with the usual Linux commands, I guess the ssh commands needs the environment variables to connect to the authentication socket and the agent's pid? How do I obtain these?
          Hide
          kossmoboleat Tim Benke added a comment -

          Ok, I've understood a bit more by reading the source code and looking up how ssh agents work.

          When executing the released 1.13 version of the plugin even with a more up-to-date jenkins version 2.19.1, it seems to continue with the correct PATH settings and some private key format.

          Then no matter what I tried, it failed when actually trying the connection to the opened authentication socket. I think mina crashed when using the tomcat native library. This happened 100% of the time with the latest 1.2 and 1.1 versions of tomcat native lib. I can only speculate where the error occurs in mina, tomcat native the jdk or ssh-agent-plugin.

          Instead of pursuing this further I got the new implementation referenced in another pull request to work. For this I had to add the commands for ssh-agent, ssh-add and ssh to the PATH. I chose the MSYS implementations which come for example with Git for Windows.

          This is my new working output, even though it says that my passphrase is incorrect:

          Started by user Admin
          Building in workspace D:\jenkins\workspace\freestyletest
          [ssh-agent] Looking for ssh-agent implementation...
          [ssh-agent] Exec ssh-agent (binary ssh-agent on a remote machine)
          ExecRemoteAgent::execProcess - ssh-agent
          SSH_AUTH_SOCK=/tmp/ssh-RzehojsjMh0s/agent.10052
          SSH_AGENT_PID=6364
          [ssh-agent] Started.
          ExecRemoteAgent::execProcess - ssh-add C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key
          Identity added: C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key (C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key)
          Check the passphrase for the private key.
          [ssh-agent] Using credentials usertest-ppk
          [freestyletest] $ cmd /c call C:\Users\win-user\AppData\Local\Temp\2\hudson3324413359897918200.bat

          D:\jenkins\workspace\freestyletest>ssh usertest@target-machine uname -a
          Linux target-machine 2.6.32-642.6.2.el6.x86_64 #1 SMP Mon Oct 24 10:22:33 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

          D:\jenkins\workspace\freestyletest>exit 0
          [freestyletest] $ D:\Applications\Git\bin\bash.exe -xe C:\Users\win-user\AppData\Local\Temp\2\hudson7861758823746367406.sh
          ExecRemoteAgent::execProcess - ssh-agent -k
          [ssh-agent] Stopped.
          Finished: SUCCESS

          Show
          kossmoboleat Tim Benke added a comment - Ok, I've understood a bit more by reading the source code and looking up how ssh agents work. When executing the released 1.13 version of the plugin even with a more up-to-date jenkins version 2.19.1, it seems to continue with the correct PATH settings and some private key format. Then no matter what I tried, it failed when actually trying the connection to the opened authentication socket. I think mina crashed when using the tomcat native library. This happened 100% of the time with the latest 1.2 and 1.1 versions of tomcat native lib. I can only speculate where the error occurs in mina, tomcat native the jdk or ssh-agent-plugin. Instead of pursuing this further I got the new implementation referenced in another pull request to work. For this I had to add the commands for ssh-agent, ssh-add and ssh to the PATH. I chose the MSYS implementations which come for example with Git for Windows. This is my new working output, even though it says that my passphrase is incorrect: Started by user Admin Building in workspace D:\jenkins\workspace\freestyletest [ssh-agent] Looking for ssh-agent implementation... [ssh-agent] Exec ssh-agent (binary ssh-agent on a remote machine) ExecRemoteAgent::execProcess - ssh-agent SSH_AUTH_SOCK=/tmp/ssh-RzehojsjMh0s/agent.10052 SSH_AGENT_PID=6364 [ssh-agent] Started. ExecRemoteAgent::execProcess - ssh-add C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key Identity added: C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key (C:\Users\win-user\AppData\Local\Temp\2\private_key_5856559581783937046.key) Check the passphrase for the private key. [ssh-agent] Using credentials usertest-ppk [freestyletest] $ cmd /c call C:\Users\win-user\AppData\Local\Temp\2\hudson3324413359897918200.bat D:\jenkins\workspace\freestyletest>ssh usertest@target-machine uname -a Linux target-machine 2.6.32-642.6.2.el6.x86_64 #1 SMP Mon Oct 24 10:22:33 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux D:\jenkins\workspace\freestyletest>exit 0 [freestyletest] $ D:\Applications\Git\bin\bash.exe -xe C:\Users\win-user\AppData\Local\Temp\2\hudson7861758823746367406.sh ExecRemoteAgent::execProcess - ssh-agent -k [ssh-agent] Stopped. Finished: SUCCESS
          Hide
          jglick Jesse Glick added a comment -

          Try 1.14 and the native command.

          Show
          jglick Jesse Glick added a comment - Try 1.14 and the native command.

            People

            • Assignee:
              Unassigned
              Reporter:
              kossmoboleat Tim Benke
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: