• Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • ssh-agent-plugin
    • Windows 2012
      Tomcat 8.0 with native library
      Jenkins 1.610
      ssh-agent plugin 1.6

      Getting the following exception when attempt to run a job with the ssh-agent plugin enabled:

        Started by user anonymous
        Building in workspace C:\Program Files (x86)\Jenkins\jobs\SmartPhone\workspace
        [ssh-agent] Using credentials id_rsa_smartphone (Smartphone Repo on GitHub)
        [ssh-agent] Looking for ssh-agent implementation...
        [ssh-agent] FATAL: Could not find a suitable ssh-agent provider
        [ssh-agent] Diagnostic report
        FATAL: [ssh-agent] Unable to start agent
        hudson.util.IOException2: [ssh-agent] Unable to start agent
        	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.createSSHAgentEnvironment(SSHAgentBuildWrapper.java:231)
        	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.preCheckout(SSHAgentBuildWrapper.java:189)
        	at jenkins.scm.SCMCheckoutStrategy.preCheckout(SCMCheckoutStrategy.java:76)
        	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
        	at hudson.model.Run.execute(Run.java:1741)
        	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
        	at hudson.model.ResourceController.execute(ResourceController.java:98)
        	at hudson.model.Executor.run(Executor.java:374)
        Caused by: java.lang.RuntimeException: [ssh-agent] Could not find a suitable ssh-agent provider.
        	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper$SSHAgentEnvironment.<init>(SSHAgentBuildWrapper.java:332)
        	at com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper.createSSHAgentEnvironment(SSHAgentBuildWrapper.java:224)
        	... 7 more
        Finished: FAILURE
      

      I'm not a Java developer but It appears that the code is attempting to get implementors of RemoteAgentFactory. From what I can tell, there are two - MinaRemoteAgentFactory and JNRRemoteAgentFactory. However, it doesn't appear to find either of these two because of the FATAL: Could not find a suitable ssh-agent provider message that it emits. If it did find MinaRemoteAgentFactory, the MinaRemoteAgentFactory.isSupported() function would either return true or log the Could not find Tomcat Native library message.

      I'm not positive that I have the Tomcat native library installed correctly but it appears that it is not even getting to the point where it's checking for the existence of the library. When I installed Tomcat on Windows, I selected the option to include the native library. In the Tomcat logs, it indicates that the native library is being used.

          [JENKINS-28279] Could not find a suitable ssh-agent provider.

          cowwoc added a comment -

          Will's installation instructions for Windows worked perfectly (hint: Jenkins expects a 32-bit DLL, even on a 64-bit OS). To the author of this plugin, please update the official documentation with these steps!

          cowwoc added a comment - Will's installation instructions for Windows worked perfectly (hint: Jenkins expects a 32-bit DLL, even on a 64-bit OS). To the author of this plugin, please update the official documentation with these steps!

          Joe George added a comment -

          Worked for me too. Howerver, I used chocolatey to install tomcat instead.

          I also see this issue though:

          debug1: pubkey_prepare: ssh_get_authentication_socket: Device or resource busy
          

          Anyone have any ideas?

          Joe George added a comment - Worked for me too. Howerver, I used chocolatey to install tomcat instead. I also see this issue though: debug1: pubkey_prepare: ssh_get_authentication_socket: Device or resource busy Anyone have any ideas?

          cowwoc added a comment - - edited

          I could swear I had this working recently (as mentioned above) but now I am getting a slightly different problem from you guys. I had this working in the past, but it now looks like I am getting a different problem from you.

          1. ssh-agent seems to launch successfully:

          [ssh-agent] Using credentials cowwoc
          [ssh-agent] Looking for ssh-agent implementation...
          [ssh-agent]   Java/tomcat-native ssh-agent
          [ssh-agent] Registered BouncyCastle on the remote agent
          [ssh-agent] Started.
          

          2. But git.exe is not using it:

          debug1: Authentications that can continue: publickey
          debug1: Next authentication method: publickey
          debug1: Offering RSA public key: /c/Users/builds/.ssh/id_rsa
          debug1: Server accepts key: pkalg ssh-rsa blen 535
          debug1: read_passphrase: can't open /dev/tty: No such device or address
          

          (I got the above debugging output by setting system property GIT_SSH_COMMAND="ssh -v" as mentioned at http://stackoverflow.com/a/36038548/14731)

          UPDATE: I think I get it now. "git in a shell" works fine, but "git plugin" is not. This seems to be a known problem. See https://groups.google.com/forum/#!topic/jenkinsci-users/4yXiBwwthMg

          At first glance, it seems you can workaround this problem by using an HTTPS URL for "git checkout" (as opposed to ssh). This gets around the "git plugin" bug (it uses the credentials from Jenkins instead of from ssh-agent).

          cowwoc added a comment - - edited I could swear I had this working recently (as mentioned above) but now I am getting a slightly different problem from you guys. I had this working in the past, but it now looks like I am getting a different problem from you. 1. ssh-agent seems to launch successfully: [ssh-agent] Using credentials cowwoc [ssh-agent] Looking for ssh-agent implementation... [ssh-agent] Java/tomcat- native ssh-agent [ssh-agent] Registered BouncyCastle on the remote agent [ssh-agent] Started. 2. But git.exe is not using it: debug1: Authentications that can continue : publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /c/Users/builds/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 535 debug1: read_passphrase: can't open /dev/tty: No such device or address (I got the above debugging output by setting system property GIT_SSH_COMMAND="ssh -v" as mentioned at http://stackoverflow.com/a/36038548/14731 ) UPDATE : I think I get it now. "git in a shell" works fine, but "git plugin" is not. This seems to be a known problem. See https://groups.google.com/forum/#!topic/jenkinsci-users/4yXiBwwthMg At first glance, it seems you can workaround this problem by using an HTTPS URL for "git checkout" (as opposed to ssh). This gets around the "git plugin" bug (it uses the credentials from Jenkins instead of from ssh-agent).

          Will Saxon added a comment -

          FWIW I don't think I ever got this to work on Windows with Git. I haven't really tried since I put in my original comment last year. At the time, I was getting the same 'device or resource busy' error that Joe got. I assumed it was something with how the socket file/handle was being presented; I've seen where e.g. applications have different methods of writing a file for cygwin- vs. msys-based client applications, whereas Windows/winsock may have a 3rd format.

          I am not sure why this would be needed for the Git plugin, as it already works with SSH Credentials. For some of our other non-plugin git needs I've either stashed an ssh key on the build machine, or it's possible (but messy) to write a groovy script in EnvInject which will use the job's configured git with programmed credentials.

          Will Saxon added a comment - FWIW I don't think I ever got this to work on Windows with Git. I haven't really tried since I put in my original comment last year. At the time, I was getting the same 'device or resource busy' error that Joe got. I assumed it was something with how the socket file/handle was being presented; I've seen where e.g. applications have different methods of writing a file for cygwin- vs. msys-based client applications, whereas Windows/winsock may have a 3rd format. I am not sure why this would be needed for the Git plugin, as it already works with SSH Credentials. For some of our other non-plugin git needs I've either stashed an ssh key on the build machine, or it's possible (but messy) to write a groovy script in EnvInject which will use the job's configured git with programmed credentials.

          Joe George added a comment -

          I'm going to file a new issue regarding debug1: pubkey_prepare: ssh_get_authentication_socket: Device or resource busy.

          Joe George added a comment - I'm going to file a new issue regarding debug1: pubkey_prepare: ssh_get_authentication_socket: Device or resource busy .

          cowwoc added a comment -

          As far as I can tell, the only way to authenticate properly under Windows is to pass the username/password to an HTTPS url. See http://stackoverflow.com/a/33630506/14731 and JENKINS-28335 for more details.

          cowwoc added a comment - As far as I can tell, the only way to authenticate properly under Windows is to pass the username/password to an HTTPS url. See http://stackoverflow.com/a/33630506/14731 and JENKINS-28335 for more details.

          Joe George added a comment - - edited

          In the end I just wrote a new plugin to spawn an actual ssh-agent.exe process. It's loaded by the ssh-agent plugin so no changes are necessary to pipelines or anything .

          If you're interested I can share once I clean it up a little.

          Joe George added a comment - - edited In the end I just wrote a new plugin to spawn an actual ssh-agent.exe process. It's loaded by the ssh-agent plugin so no changes are necessary to pipelines or anything . If you're interested I can share once I clean it up a little.

          cowwoc added a comment -

          externl For sure, share it. Ideally the author of this plugin will pull in your changes so we will get it out of the box standard.

          cowwoc added a comment - externl For sure, share it. Ideally the author of this plugin will pull in your changes so we will get it out of the box standard.

          Jesse Glick added a comment -

          JENKINS-36997 in 1.14 does that in this plugin.

          Jesse Glick added a comment - JENKINS-36997 in 1.14 does that in this plugin.

          Jesse Glick added a comment -

          Jesse Glick added a comment - Close if https://github.com/jenkinsci/ssh-agent-plugin/pull/48 is merged.

            Unassigned Unassigned
            ronrat Ron Ratzlaff
            Votes:
            8 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: