0
0
JenkinsHow-ToBeginner · 3 min read

How to Unlock Jenkins: Step-by-Step Guide

To unlock Jenkins after installation, locate the initialAdminPassword file inside the Jenkins home directory (usually /var/lib/jenkins/secrets/initialAdminPassword), copy the password, and enter it on the Jenkins unlock page. Alternatively, delete the initialAdminPassword file to reset the unlock process.
📐

Syntax

The unlock process involves reading the initial admin password from a file and entering it in Jenkins UI.

  • /var/lib/jenkins/secrets/initialAdminPassword: File containing the unlock password.
  • Jenkins unlock page: Web interface where you paste the password.
  • Deleting the password file resets the unlock state.
bash
cat /var/lib/jenkins/secrets/initialAdminPassword
Output
e3f1a2b4c5d67890abcdef1234567890
💻

Example

This example shows how to find and use the initial admin password to unlock Jenkins.

bash
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Output
e3f1a2b4c5d67890abcdef1234567890
⚠️

Common Pitfalls

1. Wrong file path: The password file location may differ based on OS or Jenkins setup.

2. Permission denied: You may need sudo to read the password file.

3. Forgetting to restart Jenkins: After deleting the password file, restart Jenkins to regenerate it.

bash
cat /var/lib/jenkins/secrets/initialAdminPassword
# Permission denied error

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
# Correct way to read the file
Output
cat: /var/lib/jenkins/secrets/initialAdminPassword: Permission denied e3f1a2b4c5d67890abcdef1234567890
📊

Quick Reference

ActionCommand / Location
View unlock passwordsudo cat /var/lib/jenkins/secrets/initialAdminPassword
Unlock JenkinsPaste password on Jenkins unlock web page
Reset unlocksudo rm /var/lib/jenkins/secrets/initialAdminPassword && sudo systemctl restart jenkins
Jenkins home directory/var/lib/jenkins

Key Takeaways

Find the initial admin password in /var/lib/jenkins/secrets/initialAdminPassword to unlock Jenkins.
Use sudo if you get permission errors reading the password file.
Deleting the password file and restarting Jenkins resets the unlock process.
Always paste the exact password from the file into the Jenkins unlock page.
Unlocking Jenkins is required only once after installation.