0
0
Jenkinsdevops~10 mins

Agent connection methods (SSH, JNLP) in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Agent connection methods (SSH, JNLP)
Start Jenkins Master
Choose Agent Connection Method
SSH Agent
Master connects
Agent ready for jobs
Run Jobs
Jenkins master and agent connect using either SSH where master initiates connection, or JNLP where agent initiates connection, enabling job execution.
Execution Sample
Jenkins
ssh-agent setup:
ssh user@agent-host

jnlp-agent setup:
java -jar agent.jar -jnlpUrl http://master/computer/agent/slave-agent.jnlp
Shows commands to connect Jenkins agent via SSH and JNLP methods.
Process Table
StepActionConnection MethodResultNext Step
1Jenkins master startsN/AMaster readyChoose agent connection method
2Select SSH methodSSHMaster prepares SSH connectionMaster connects to agent via SSH
3Master runs ssh user@agent-hostSSHSSH session establishedAgent ready for jobs
4Agent accepts SSH connectionSSHAgent connectedRun jobs on agent
5Select JNLP methodJNLPAgent downloads agent.jarAgent runs java -jar agent.jar
6Agent runs java -jar with JNLP URLJNLPAgent connects to masterAgent ready for jobs
7Agent connected via JNLPJNLPAgent connectedRun jobs on agent
8Jobs dispatchedSSH or JNLPJobs run on agentExecution complete
💡 Jobs run on agent; connection established either by SSH initiated by master or JNLP initiated by agent.
Status Tracker
VariableStartAfter SSH ConnectAfter JNLP ConnectFinal
Connection StatusDisconnectedConnected (SSH)Connected (JNLP)Connected
Agent ReadyNoYes (SSH)Yes (JNLP)Yes
Key Moments - 2 Insights
Why does SSH connection start from the master but JNLP connection starts from the agent?
SSH requires master to initiate connection to agent's SSH server (see execution_table step 3), while JNLP agent runs on the agent machine and connects back to master (see step 6).
What happens if the agent machine blocks incoming SSH connections?
SSH connection will fail at step 3 in execution_table, but JNLP can still work because agent initiates connection outbound to master (step 6).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the agent initiate the connection to the master?
AStep 3
BStep 6
CStep 4
DStep 2
💡 Hint
Check the 'Action' and 'Connection Method' columns for JNLP where agent runs java -jar to connect.
According to the variable tracker, what is the connection status after SSH connect?
ADisconnected
BConnected (JNLP)
CConnected (SSH)
DConnecting
💡 Hint
Look at the 'Connection Status' row under 'After SSH Connect' column.
If the agent blocks incoming SSH but allows outbound connections, which method will succeed?
AJNLP only
BBoth SSH and JNLP
CSSH only
DNeither
💡 Hint
Refer to key_moments explanation about connection initiation direction.
Concept Snapshot
Jenkins agents connect to master via two main methods:
- SSH: Master initiates connection to agent's SSH server.
- JNLP: Agent runs a Java client that connects back to master.
SSH requires agent to accept incoming connections.
JNLP works well when agent cannot accept inbound connections.
Both enable agents to run jobs dispatched by master.
Full Transcript
This visual execution shows how Jenkins agents connect to the master using SSH or JNLP methods. The master starts and chooses the connection method. For SSH, the master initiates an SSH session to the agent machine, which must accept incoming SSH connections. For JNLP, the agent machine runs a Java client that connects back to the master, useful when the agent cannot accept inbound connections. The execution table traces each step from starting the master, selecting connection method, establishing connection, to running jobs. The variable tracker shows connection status and agent readiness changing from disconnected to connected. Key moments clarify why connection initiation direction matters and what happens if SSH is blocked. The quiz tests understanding of connection initiation steps and conditions for success. The snapshot summarizes the two methods and their key differences.