The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

SSH Agent Plugin

sshagent: SSH Agent


node {
  sshagent (credentials: ['deploy-dev']) {
    sh 'ssh -o StrictHostKeyChecking=no -l cloudbees 192.168.1.106 uname -a'
  }
}

Multiple credentials could be passed in the array but it is not supported using Snippet Generator.

  • credentials : Array / List of String
    List of credentials to be used by the sshagent step. The Pipeline Syntax Snippet Generator will guide the user to select a single credential from the list of available, like this:
    sshagent(credentials: ['my-credential-id']) {
        // some block
    }
    
    The step also accepts a list of credentials, like this:
    sshagent(credentials: ['my-credential-id', 'my-alternate-credential', 'another-credential']) {
        // some block
    }
    
    • executable : String (optional)
      The path of the SSH agent executable to run. Defaults to ssh-agent searched on the PATH of the executing computer.
    • ignoreMissing : boolean (optional)
      When set to true, any missing credentials will be ignored. When set to false, then the build fails if any of the required credentials cannot be resolved. Defaults to false.
    • timeoutMinutes : int (optional)
      How long, in minutes, to wait for each of the ssh-agent, ssh-add and ssh-agent -k commands before giving up. Defaults to one minute. Raise it on slow environments where ssh-add needs more time. Values below one are treated as one.
    • usernameVariable : String (optional)
      If set, the username of the first resolved credential is exposed under this environment variable inside the block, so it can be passed to ssh -l "$SSH_USER". Leave it empty to not expose the username.

    Was this page helpful?

    Please submit your feedback about this page through this quick form.

    Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

        


    See existing feedback here.