๐–๐ก๐š๐ญ ๐ข๐ฌ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ? ๐–๐ก๐ฒ ๐๐จ ๐ฐ๐ž ๐ง๐ž๐ž๐ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ? A๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ ? how to connect ?

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ? ๐–๐ก๐ฒ ๐๐จ ๐ฐ๐ž ๐ง๐ž๐ž๐ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ? A๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ ? how to connect ?

ยท

4 min read

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ?

A Jenkins Agent is like a helpful ๐ฆ๐ข๐ง๐ข๐จ๐ง ๐Ÿ‘ทโ€โ™‚๏ธ for Jenkins, doing tasks remotely on other computers for you!

๐–๐ก๐ฒ ๐๐จ ๐ฐ๐ž ๐ง๐ž๐ž๐ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ?

๐Ÿค– To share the workload and conquer the Jenkins universe with teamwork and efficiency! ๐Ÿš€

๐–๐ก๐š๐ญ ๐š๐ซ๐ž ๐ญ๐ก๐ž ๐š๐๐ฏ๐š๐ง๐ญ๐š๐ ๐ž๐ฌ ๐จ๐Ÿ ๐ฎ๐ฌ๐ข๐ง๐  ๐ข๐ญ?

Faster, automated, saves time, and no need to do all the work yourself! ๐Ÿ˜„๐Ÿค–

๐‡๐จ๐ฐ ๐œ๐š๐ง ๐ฐ๐ž ๐œ๐จ๐ง๐ง๐ž๐œ๐ญ ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐€๐ ๐ž๐ง๐ญ(Slave) ๐ฐ๐ข๐ญ๐ก ๐š ๐‰๐ž๐ง๐ค๐ข๐ง๐ฌ ๐Œ๐š๐ฌ๐ญ๐ž๐ซ?

To install Jenkins please go through with previous blog here is the link

https://param036.hashnode.dev/jenkins-tutorials

In this blog, I'm going to explain

how to connect the slave node with the Jenkins master through SSH (Secure Shell).

Jenkins Agent:-

A Jenkins agent is like a trusty sidekick for your Jenkins server ๐Ÿฆธโ€โ™‚๏ธ๐Ÿค–! It's a helper bot that goes out into the world ๐ŸŒ (or your computer network) to do tasks for Jenkins. Think of it as Jenkins' minion, running around and doing all the heavy lifting so Jenkins doesn't have to break a sweat! ๐Ÿ’ช๐Ÿ˜„

first, access your Jenkins master Dashboard.

Then click on Manage Jenkins

click here

After clicking on manage Jenkins click on the plugin

Now click on the available plugin and search for SSH .

select the SSH and SSH server

SSH:- This plugin executes shell commands remotely using SSH protocol.

SSH server:- Adds SSH server functionality to Jenkins, exposing CLI commands through it.

Now click on Install in the top right-hand side

and wait till all plugins get downloaded successfully. After completion of download you'll able to see like this then click on Go back to top page .

It will redirect to the main Jenkins dashboard

now again click on the manage Jenkins -> Security

here we have been unable the SSH connection request

In Security make the TCP protocol to Random And Scroll down to the SSH server

In the SSH server change the SSHD port to fixed and enter port number 22

as we know SSH listens the port 22.

Now click on apply then save to save the cofigurations.

It will again redirect to the main Jenkins dashboard

Now we'll add the Slave node.

Before that

Take access to the slave node and configure it

This is the terminal of the slave node

change the root user password or else we can add a new user and you can access the new user through the Jenkins master.

here I'm going with the root user only

passwd root

Enter the password anything as per your wish and confirm it again by entering the password.

After setting the password open the sshd_config file using

vi /etc/ssh/sshd_config

In this file add the PermitRootLogin yes (anywhere you can add it)

PermitRootLogin yes

And

PasswordAuthentication yes

Before

After editing it looks like this saves the file using:wq!

Now after saving the file restart the sshd using

systemctl restart sshd

Now update the slave node

apt update -y

Now Install the Java in the slave node using

apt install default-jre

Confirmation type Y

Now Install the Jdk as well

apt install default-jdk

Confirmation type Y

now check the Java is installed or not

java -version

Again go back to the Jenkins Master dashboard

Now click on manage Jenkins -> Nodes

Now click on New node

Give the Node name and type

then click on create.

When we add a node for the first time we get only a single option โ€œPermanent Agentโ€, but after adding a slave you will get another option. This option will allow you to copy the node from another node which is named as โ€œCopy Existing Nodeโ€

Provide the remote directory where we want to build the jobs on slave_node

root directory = /root (I'm preferring this)

labels anything = paramnode (Identification Mark)

In the Launch method select Launch agents via SSH

In Host = public or private ip of the slave node

credentials = add-> Jenkins

Add credentials to move you to a new popup page.

Here select

Domain = Global credentials

kind = Username and password

username = root (whichever you're added on the slave node)

password = password of the created user on the slave node

In my case, i have set the password to the root user only

ID = Anything Not mandatory

After adding this all things

now again click on Credentials? now you're able to see the added Credentials

Before it was None

Select the root/****

Host Key Verification Strategy = Non-verifying Verification strategy

remaining to keep it as it is and click on save

Here we can see our slave_node_1 is connected with the Jenkins master

We can check the logs of it as well

click on the node name which is ***slave_node_***1 on the left-hand side then log

Thank you!!

Follow me for more content like this

please put your query in the comment box or send a mail.

ย