0
0
Jenkinsdevops~20 mins

Agent connection methods (SSH, JNLP) in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Agent Connection Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Jenkins Agent Connection Methods

Which statement correctly describes the difference between SSH and JNLP agent connection methods in Jenkins?

AJNLP agents require Jenkins to have SSH access to the agent machine, but SSH agents do not require any network connection.
BSSH agents use a Java Web Start protocol, while JNLP agents use direct SSH commands to connect.
CSSH agents connect by Jenkins initiating an SSH session to the agent machine, while JNLP agents connect by the agent machine initiating a connection to Jenkins.
DBoth SSH and JNLP agents require the agent machine to open port 22 for Jenkins to connect.
Attempts:
2 left
💡 Hint

Think about who starts the connection in each method.

💻 Command Output
intermediate
2:00remaining
Output of Starting a JNLP Agent Manually

What is the expected output when running the following command on the agent machine to start a JNLP agent?

Jenkins
java -jar agent.jar -jnlpUrl http://jenkins.example.com/computer/agent1/slave-agent.jnlp -secret 1234567890abcdef
A
INFO: Connecting to Jenkins at http://jenkins.example.com
INFO: Connected
INFO: Agent started successfully
B
ERROR: Could not find agent.jar file
Exception in thread "main" java.lang.NoClassDefFoundError
C
INFO: SSH connection established
INFO: Agent ready
D
ERROR: Invalid secret key
Connection refused
Attempts:
2 left
💡 Hint

JNLP agents connect using Java and a secret key.

Configuration
advanced
2:00remaining
Configuring SSH Agent in Jenkins

Which SSH configuration snippet correctly sets up a Jenkins agent to connect via SSH with a private key located at /home/jenkins/.ssh/id_rsa?

A
Host agent1
  HostName agent1.example.com
  User jenkins
  IdentityFile /home/jenkins/.ssh/id_rsa
  StrictHostKeyChecking no
B
Host agent1
  HostName agent1.example.com
  User jenkins
  PasswordAuthentication yes
  IdentityFile /home/jenkins/.ssh/id_rsa
C
Host agent1
  HostName agent1.example.com
  User root
  IdentityFile /root/.ssh/id_rsa
  StrictHostKeyChecking no
D
Host agent1
  HostName agent1.example.com
  User jenkins
  IdentityFile /home/jenkins/.ssh/id_rsa
  Port 8080
Attempts:
2 left
💡 Hint

Check the user, key file path, and SSH options for security.

Troubleshoot
advanced
2:00remaining
Troubleshooting SSH Agent Connection Failure

A Jenkins SSH agent fails to connect with the error: Permission denied (publickey). Which is the most likely cause?

AThe Jenkins master is not running the Java agent jar.
BThe agent machine's firewall is blocking port 8080.
CThe JNLP secret key is incorrect.
DThe private key on Jenkins master does not match the public key on the agent machine.
Attempts:
2 left
💡 Hint

Think about SSH authentication errors.

Best Practice
expert
2:00remaining
Choosing Agent Connection Method for Security and Scalability

For a Jenkins setup with many dynamic cloud agents behind firewalls, which agent connection method is best practice and why?

AUse JNLP agents because they require Jenkins to open SSH ports on all agents.
BUse JNLP agents because they initiate the connection to Jenkins, avoiding firewall inbound rules.
CUse SSH agents because Jenkins can directly connect to all agents via SSH without extra setup.
DUse SSH agents because they are easier to configure on cloud providers.
Attempts:
2 left
💡 Hint

Consider firewall and network restrictions for cloud agents.