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

ssh-agent not applied in kubernetes container

    XMLWordPrintable

Details

    Description

      the ssh-agent configuration isn't applied when pipeline is run on a docker container using the kubernetes plugin

       

      as an example, this pipeline works fine:

      sshagent in basic pipeline
      node {
          stage('Pre-Build') {
              sshagent (credentials: ['jenkins-master-ssh']) {
                  sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com'
              }
          }
      }
      

      the job will fail, but the console output will clearly show the error from github 

      You've successfully authenticated, but GitHub does not provide shell access.

       

      whereas

      sshagent not applied in container 
      podTemplate(label: 'jenkpod', containers: [containerTemplate(name: 'golang', image: 'golang:1.8', ttyEnabled: true, command: 'cat')]) {
          node ('jenkpod') { container('golang') {
      
              stage('Pre-Build') {
                  sshagent (credentials: ['jenkins-master-ssh']) {
                      sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com'
                  }
              }
      
          } }
      }
      

      fails with public key error:

      debug1: Authentications that can continue: publickey
      debug1: Next authentication method: publickey
      debug1: Trying private key: /root/.ssh/id_rsa
      debug1: Trying private key: /root/.ssh/id_dsa
      debug1: Trying private key: /root/.ssh/id_ecdsa
      debug1: Trying private key: /root/.ssh/id_ed25519
      debug1: No more authentication methods to try.
      Permission denied (publickey).

       

      this seems closely related to -JENKINS-32624 sshagent{} ignored when executed in docker.image().inside

       

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            akmjenkins whatever you are seeing, it sounds like an unrelated issue, and perhaps just a user error—incorrect pod definition.

            jglick Jesse Glick added a comment - akmjenkins whatever you are seeing, it sounds like an unrelated issue, and perhaps just a user error—incorrect pod definition.
            akmjenkins ASHOK MOHANTY added a comment -

            Thanks, able to catch the user  code issue.

            akmjenkins ASHOK MOHANTY added a comment - Thanks, able to catch the user  code issue.
            markewaite Mark Waite added a comment -

            ac77 asking for help through a closed Jenkins issue report is much less likely to receive help than asking for help through a message on the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list. There are 23 people watching this issue and likely 10x more than that reading those other lists. Please use the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list to ask for help.

            markewaite Mark Waite added a comment - ac77 asking for help through a closed Jenkins issue report is much less likely to receive help than asking for help through a message on the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list. There are 23 people watching this issue and likely 10x more than that reading those other lists. Please use the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list to ask for help.
            ac77 Amit added a comment -

            Hi all !

            I'm getting the error "Host key verification failed" when trying to authenticate with ssh for a git push operation from a worker container in Kubernetes pod.

            I run podTemplate with a worker image based on alpine with git version 2.32.0

            Jenkins version is 2.303.3

            Kubernetes plugin version 1.30.7

            The first operation of git clone succeeds but then when trying to push tags to a remote (gitlab) repository I get the error.

            Attached is the Jenkins console output.

            Am I missing something ? 

            Any help is appreciated.

            Thanks,

            AC

            amidar

            ac77 Amit added a comment - Hi all ! I'm getting the error "Host key verification failed" when trying to authenticate with ssh for a git push operation from a worker container in Kubernetes pod. I run podTemplate with a worker image based on alpine with git version 2.32.0 Jenkins version is 2.303.3 Kubernetes plugin version 1.30.7 The first operation of git clone succeeds but then when trying to push tags to a remote (gitlab) repository I get the error. Attached is the Jenkins console output. Am I missing something ?  Any help is appreciated. Thanks, AC amidar
            markewaite Mark Waite added a comment -

            ac77 asking for help through a closed Jenkins issue report is much less likely to receive help than asking for help through a message on the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list. There are 23 people watching this issue and likely 10x more than that reading those other lists. Please use the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list to ask for help.

            markewaite Mark Waite added a comment - ac77 asking for help through a closed Jenkins issue report is much less likely to receive help than asking for help through a message on the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list. There are 23 people watching this issue and likely 10x more than that reading those other lists. Please use the Jenkins discourse site, the Jenkins gitter chat channel, or the Jenkins user mailing list to ask for help.

            People

              seakip18 Matthew Ludlum
              jknurek J Knurek
              Votes:
              6 Vote for this issue
              Watchers:
              23 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: