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

Viewed 19248

I'm trying to run remote commands using ssh from jenkinsfile. For this I'm using *.pem file for accessing the remote machine. I already have jenkins credentials created with the type "SSH Username with private key" inside jenkins.

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

1 Answers
Related