Setup a password less ssh authentication for <<user>> on EC2 node
- Login to AWS EC2 node
- su to the user where you would setup jenkins slave
- create a key value pair
- add pub part of the key value pair to the authorized_keys
- copy the private part of the key value pair into a local file. Name it as <<user>>.pem
- chmod 400 <<user>>.pem
- test ssh to the ec2 node as <<user>> from local
- ssh -i <<user>>.pem <<user>>@ec2-node
Add ec2 node as slave node in jenkins
- scp the pem file to the jenkins master server
- Login to jenkins UI as admin
- Go to Jenkins —> Manage Jenkins –> Manage Nodes —> New Node
- provide /home/<<user>> as remote FS root
- click on advanced button
- provide hostname and user name
- leave password blank
- specify absolute path to the pem file for this <<user>>
- save and launch slave
Configure jenkins jobs to run on ec2 slave node
- go to jenkins job that you want to run remotely
- click on “Restrict where this project can be run”
- specify the slave name as “Label Expression”
- save the job and build.