• Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • ssh-steps-plugin
    • None

      Currently we need to use

      withCredentials
      

      to map the credentials to all the steps, it would nice to have credentials store integrated to read the credentials from store. 

          [JENKINS-55817] Support Credentials store for SSH Steps

          Naresh Rayapati created issue -
          Naresh Rayapati made changes -
          Description Original: Currently we need to use `withCredentials` to map the credentials to all the steps, it would nice to have credentials store integrated to read the credentials from store.  New: Currently we need to use
          {code:java}
          withCredentials
          {code}
           to map the credentials to all the steps, it would nice to have credentials store integrated to read the credentials from store. 
          Naresh Rayapati made changes -
          Link New: This issue blocks SECURITY-1259 [ SECURITY-1259 ]
          Aleksandr made changes -
          Attachment New: Screenshot 2024-02-28 at 16.51.56.png [ 62148 ]

          Aleksandr added a comment -

          Had the same issue. As a workaround, I'd created a function like:

          def login(String ip, skey) {
            remote=[:]
            remote.name='the remote server'
            remote.host="${ip}"
            remote.user='jenkins'
            remote.allowAnyHosts = true
            remote.identityFile="{skey}"
            return remote
          }

          Set the environment variables:

              environment {
                  SSH_HOST1=credentials('host1')
                  SSH_HOST2=credentials('host2')
              } 

          And then used the function in the steps with corresponding values like:

                  stage('Test') {
                      steps {
                          login('10.0.51.145', env.SSH_HOST1)
                          sshCommand remote: remote, command: "ip a"
                      } 

          Works fine for me.

           

           

          Aleksandr added a comment - Had the same issue. As a workaround, I'd created a function like: def login( String ip, skey) {   remote=[:]   remote.name= 'the remote server'   remote.host= "${ip}"   remote.user= 'jenkins'   remote.allowAnyHosts = true   remote.identityFile= "{skey}"   return remote } Set the environment variables:   environment {         SSH_HOST1=credentials( 'host1' )       SSH_HOST2=credentials( 'host2' )     } And then used the function in the steps with corresponding values like:       stage( 'Test' ) {             steps {                 login( '10.0.51.145' , env.SSH_HOST1)                 sshCommand remote: remote, command: "ip a"             } Works fine for me.    

            nrayapati Naresh Rayapati
            nrayapati Naresh Rayapati
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: