My aim is to execute shell commands on an EC2 instance as part of Jenkins job.
So I'm trying to SSH into an EC2 Instance with a private key pem file which is password protected from Jenkins build job, what are the ideal ways to do that?
Login to jenkins
Create a "New item" or in your existing jenkins job do following
Goto "General" tab
Now under "Build>Execute shell>command"
write your command to ssh to the EC2 instance
ssh ec2-user@ 'bash -s' < script.sh
Is this helpful!!
As suggested in the comments by burnettk, the plugin: Publish Over SSH was helpful in my scenario. I was trying to "ADD SSH Host" in Configure Section of Jenkins but got fed up with "unable to connect" message and tried Publish over SSH plugin it helped out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With