jenkins - How to use credential type "SSH Username with private key" inside jenkinsfile for pipeline job -


i'm trying run remote commands using ssh jenkinsfile. i'm using *.pem file accessing remote machine. have jenkins credentials created type "ssh username private key" inside jenkins.

is there way can use credential inside jenkinsfile instead of giving sh "ssh -i *.pem username@hostname command" authenticate?

no, need use jenkins credentials binding plugin. create binding key file, set key variable , lets mykey , can use key in build scripts cat mykey. or store in build script as:

cat mykey > sshkey chmod 600 sshkey eval `ssh-agent -s` ssh-add sshkey 

and can ssh since ssh key added post lays features of jenkins credentials binding plugin https://support.cloudbees.com/hc/en-us/articles/203802500-injecting-secrets-into-jenkins-build-jobs


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -