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

Failed to connect to repository with password-protected ssh key

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: git-client-plugin
    • Environment:
    • Similar Issues:

      Description

      Cannot connect to repository after upgrading to git-client-plugin 1.19.3. Downgrading to 1.19.2 fixes the issue. The key used to connect to the repository is password-protected.

      Logging-in into Jenkins and executing following command succeeds:

      ssh-agent bash -c 'ssh-add ~/.ssh/jenkins.opencms-core.id_rsa; git -c core.askpass=true ls-remote ssh://git@mygithubenterprise:myrepo/tests.git'

      GUI Error message:

      Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h git@mygithubenterprise:myrepo/tests.git HEAD" returned status code 128:
      stdout: 
      stderr: Permission denied (publickey). 
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      
      

      Console output if forcing build:

      Started by user myuser
      Building in workspace /srv/jenkins/jobs/Tests/jobs/kk/workspace
      Wiping out workspace first.
      Cloning the remote Git repository
      Cloning repository git@mygithubenterprise:myrepo/tests.git
       > git init /srv/jenkins/jobs/Tests/jobs/kk/workspace # timeout=10
      Fetching upstream changes from git@mygithubenterprise:myrepo/tests.git
       > git --version # timeout=10
      using GIT_SSH to set credentials jenkins.tests.id_rsa pass
       > git -c core.askpass=true fetch --tags --progress git@mygithubenterprise:myrepo/tests.git +refs/heads/*:refs/remotes/origin/*
      ERROR: Error cloning remote repo 'origin'
      hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress git@mygithubenterprise:myrepo/tests.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
      stdout: 
      stderr: Permission denied (publickey).
      fatal: Could not read from remote repository.
      
      Please make sure you have the correct access rights
      and the repository exists.
      
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1710)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1454)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:506)
      	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1013)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1053)
      	at hudson.scm.SCM.checkout(SCM.java:485)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      	at hudson.model.Run.execute(Run.java:1738)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      

        Attachments

          Activity

          Hide
          agallardo Alberto Gallardo added a comment -

          Confirmed that the version from the update center works for me.

          Show
          agallardo Alberto Gallardo added a comment - Confirmed that the version from the update center works for me.
          Hide
          markewaite Mark Waite added a comment -

          I've confirmed the update center now shows git client plugin 1.19.4. Be sure you refresh the update center by pressing the "Check Now" button in the Jenkins Update Center web page.

          Show
          markewaite Mark Waite added a comment - I've confirmed the update center now shows git client plugin 1.19.4. Be sure you refresh the update center by pressing the "Check Now" button in the Jenkins Update Center web page.
          Hide
          vanniktech Niklas Baudy added a comment -

          I'm also having the same problems when running 1.19.3. I have Jenkins on Mac also with SSH Credentials Plugin v1.11.

          Also I can't see the 1.19.4 release yet, do you know when we'll be able to see it?

          Show
          vanniktech Niklas Baudy added a comment - I'm also having the same problems when running 1.19.3. I have Jenkins on Mac also with SSH Credentials Plugin v1.11. Also I can't see the 1.19.4 release yet, do you know when we'll be able to see it?
          Hide
          agallardo Alberto Gallardo added a comment -

          If it helps, I have the 'SSH Credentials Plugin' v. 1.11 installed.

          Show
          agallardo Alberto Gallardo added a comment - If it helps, I have the 'SSH Credentials Plugin' v. 1.11 installed.
          Hide
          agallardo Alberto Gallardo added a comment -

          I'm still perplexed how you make it work in your environment.

          Re-reading my posts, I'm afraid I have confused you a bit. I'm sorry. "I'm using the ssh-agent" as in "I have installed it" (it's a GitHub Pull Request Builder dependency). The problem is that I'm not that familiarized with each plugin responsibility, and I assumed that it was a jenkins core component already being used.

          I added the ssh-agent plugin to my Jenkins installation, modified the job I had previously defined to use a passphrase protected credential for its git repository, then selected that same passphrase protected credential for use by the ssh-agent in the "Build Environment" section of the job configuration. I then encountered what appears to be JENKINS-32120 (ssh-agent fails when using a passphrase protected key).

          That confirms my findings in my previous post. Thanks!

          I'm even more perplexed because your config.xml does not include the ssh-agent build wrapper that I was expecting. Are you sure that is the job configuration file of one of the jobs using ssh-agent?

          My fault making you believe I was using it: no, I'm not using it in this job.

          I have now re-tested, removing the "ssh agent" plugin (and consequently, the "github pull request builder" plugin). The problem is always reproducible, and I can confirm that the commit revert still works (built git-client git-client-1.19.4 from github). Unfortunatelly, my jenkins doesn't see the new 1.19.4 release yet.

          Show
          agallardo Alberto Gallardo added a comment - I'm still perplexed how you make it work in your environment. Re-reading my posts, I'm afraid I have confused you a bit. I'm sorry. " I'm using the ssh-agent " as in " I have installed it " (it's a GitHub Pull Request Builder dependency). The problem is that I'm not that familiarized with each plugin responsibility, and I assumed that it was a jenkins core component already being used. I added the ssh-agent plugin to my Jenkins installation, modified the job I had previously defined to use a passphrase protected credential for its git repository, then selected that same passphrase protected credential for use by the ssh-agent in the "Build Environment" section of the job configuration. I then encountered what appears to be JENKINS-32120 (ssh-agent fails when using a passphrase protected key). That confirms my findings in my previous post . Thanks! I'm even more perplexed because your config.xml does not include the ssh-agent build wrapper that I was expecting. Are you sure that is the job configuration file of one of the jobs using ssh-agent? My fault making you believe I was using it: no, I'm not using it in this job. I have now re-tested, removing the "ssh agent" plugin (and consequently, the "github pull request builder" plugin). The problem is always reproducible, and I can confirm that the commit revert still works (built git-client git-client-1.19.4 from github). Unfortunatelly, my jenkins doesn't see the new 1.19.4 release yet.

            People

            • Assignee:
              markewaite Mark Waite
              Reporter:
              agallardo Alberto Gallardo
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: