0% found this document useful (0 votes)
166 views3 pages

Jenkins Master Slave

This document provides instructions for setting up a Jenkins master-slave configuration between two EC2 instances in AWS. It describes how to generate SSH keys to enable passwordless login, configure the Jenkins master to use the root user for improved security, and set up a new Jenkins slave node using an SSH connection with a public/private key pair for authentication.

Uploaded by

ssdasd s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views3 pages

Jenkins Master Slave

This document provides instructions for setting up a Jenkins master-slave configuration between two EC2 instances in AWS. It describes how to generate SSH keys to enable passwordless login, configure the Jenkins master to use the root user for improved security, and set up a new Jenkins slave node using an SSH connection with a public/private key pair for authentication.

Uploaded by

ssdasd s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

JENKINS MASTER SLAVE SETUP IN AWS EC2

1) To make password less connection use ssh-keygen


Ssh-keygen is a tool for creating new authentication key pairs for SSH. Such key pairs are used for
automating logins, single sign-on, and for authenticating hosts.

Let server1 - 192.168.0.1 and server2 - 192.168.0.2

STEP 1: Create Authentication SSH-Keygen Keys on 192.168.0.1


ssh-keygen -t rsa
It will ask for inputs like pass phrase at that time just press enter

STEP 2: Create .ssh Directory on – 192.168.0.2


Do normal ssh to server 2 and create .ssh directory
(or)
Create .ssh directory directly using ssh command from server1
ssh [email protected] mkdir -p .ssh

STEP 3: Upload Generated Public in server1 to server2 – from 192.168.0.1 to 192.168.0.2


cat .ssh/key.pub | ssh [email protected]'cat >> ~/.ssh/authorized_keys'

STEP 4: Set Permissions of authorized_keys on server1 and server2


ssh [email protected] "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

STEP 5: Login from 192.168.0.1 to 192.168.0.2 Server without Password


ssh [email protected]

2) Change jenkins default user to root (In AWS free account we can’t add new user with root
permission so use default root user only)

STEP 1: In /ect/sysconfig/jenkins file change JENKINS_USER="jenkins" to JENKINS_USER="root"

STEP 2: Make root as owner to all jenkins related folder & files (run the bellow commands in
master jenkins instance).
sudo chown -R root:root /var/lib/jenkins
sudo chown -R root:root /var/cache/jenkins
sudo chown -R root:root /var/log/jenkins

3) Create new slave node

STEP 1: Manage Jenksin -> Manage Nodes -> New Node


STEP 2: Any Node name and choose as permanent Agent -> ok

STEP 3: Do the below settings

Remote root directory /opt/jenkins


Create a jenkins root directory in slave instance
Example: Default path should be /opt/jenkins
sudo mkdir /opt/jenkins
sudo chown -R ec2-user:ec2-user /opt/jenkins

Launch Method Launch agent agents via SSH


(If this option not found then install SSH Slaves plugin)

HOST Public IPv4 of slave instance

Host Key Verification Strategy Manually Provided Key Verification Strategy

Credentials Add -> Jenkins


Jenkins Credentials Provider: Jenkins

Kind -> SSH username with private key


Username -> ec2-user (AWS default user)
Private Key -> enter manually
Private key of master instance created by ssh-keygen
cat ~/.ssh/ id_rsa
Save / Add

SSH Key Copy the public key of AWS slave instance here.
cat /etc/ssh/ssh_host_rsa_key.pub
Add Node snapshot

Credentials snapshot

You might also like