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

Unable to switch to a sudo user using ssh pipeline

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Major Major
    • ssh-steps-plugin
    • None
    • Production

      My task is to perform certain operations on Linux server as a sudo user. 

      Current Situation: Using the ssh pipeline plugin I am able to login into the remote server and run the command using sshCommand. 

       

      Issue: To perform other operations I need to switch to a  sudo user  with a password.  I am unable to find if this is possible with this plugin.

      Please refer to the below code and let us know you suggestions to the issue

       

      def remote = [:]
       remote.name = '<server name>'
       remote.host = '<server host name>'
       remote.user = '<userId>'
       remote.password = '<password>'
       remote.allowAnyHosts = true
       remote.agent = true
       node {
        stage('Remote SSH') {
           sshCommand remote: remote, command: "ls lrt"   Able to Execute the pipeline until here
           sshCommand remote: remote, command: "sudo su <sudo Username>",sudo: true — Not sure if this is the right usage
         }
       }
      
      

       

            nrayapati Naresh Rayapati
            agadd2 Anurag GADDAMANUGU
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: