- Как в Jenkins сбросить пароль
- Как в Jenkins сбросить пароль администратора
- Первый способ
- Второй способ
- How to Reset Jenkins Admin users Password
- Disable Jenkins Security
- Reset Jenkins Admin’s Password
- Create New Jenkins Admin User
- Conclusion
- How to Reset Jenkins Admin User Password
- Steps to Reset Jenkins Admin Password
- Conclusion
- Jenkins: Reset Admin Password
- Reset Jenkins Admin Password
Как в Jenkins сбросить пароль
В Jenkins сбросить пароль можно двумя способами. Сброс пароля нужен если авторизация через веб-интерфейс невозможна. Пароль можно изменить или задать новый предварительно выключив авторизацию.
Как в Jenkins сбросить пароль администратора
Пароль администратора иногда оказывается утерян или забыт.
Если такое произошло — можно задать новый пароль.
Первый способ
Заключается во временном отключении авторизации.
В конфигурационном файле можно поменять значение параметра, который отвечает за то будет ли запрашиваться пароль вообще
Если значение установлено в False — пароль не запрашивается.
Далее службу нужно перезапустить
systemctl restart jenkins.service
Когда эти действия проделаны — можно зайти в веб-интерфейс без пароля и установить новый пароль, с которым удобно будет работать.
Затем поменять значение на True и перезапустить Jenkins.
Минус данного подхода в том, что какое-то время Jenkins оказывается полностью открыт и зайти без пароля может кто угодно.
Второй способ
Заключается в генерации хэша и задании его в качестве пароля в конфигурационном файле
Значение генерируется так
Затем оно добавляется в /var/lib/jenkins/admin/config.xml между открывающим и закрывающим тэгами passwordHash
Изменения вступят в силу после перезапуска
systemctl restart jenkins.service
Потом нужно убедиться в том, что сервис запустился и работает
systemctl status jenkins.service
Таким образом пароля менять безопаснее, но прибегая к нему добиться результата удается не всегда.
Читайте статью про установку Jenkins и начало работы.
How to Reset Jenkins Admin users Password
In this tutorial, you will learn how to reset the admin user’s password in Jenkins.
Have you ever created a Jenkins instance for your local development needs and then forget the username you set? Don’t fret, we’ve all done this before. Thankfully, the password can be reset by doing a number of tasks from the command-line.
You will need elevated privileges to perform a Jenkins admin password reset. We will be modifying the security context of the Jenkins instance, and essentially turning authentication off temporarily.
Once we have disabled password authentication, we will log into the Jenkins web console and set a new password for our user.
Disable Jenkins Security
Log onto your Jenkins server using an account with root privileges. Once logged in, look open Jenkin’s configration XML file into a text editor.
In the example below, we are opening the file in VIM.
sudo vi /var/lib/jenkins/config.xml
With the configuration file opened, perform a search for the useSecurity string. This can be done in VIM by pressing ESC and then entering /useSecurity .
The line you are looking for should resemble the following.
Press i to enter VIM’s insert mode. Modify the value between the tags and set the value to false .
Save your changes and then exit the text editor. If you are using VIM, press ESC and then enter wq! to write your changes and then exit the editor.
Your changes will not take affect until Jenkins is restarted. Restart the service now.
sudo systemctl restart jenkins
Reset Jenkins Admin’s Password
After Jenkins restarts navigate to the web console. Notice that you were not prompted for a username or password. This is because we disabled security in Jenkins’ configuration file.
If this is a publicly shared Jenkins instance, you should disable public access to the server until the password reset is complete.
To reset admin’s password, do the following.
- Click on People on the left-hand navigation menu.
- Click on the Admin.
- Delete the user account.
- Navigate to Jenkins / Manage Jenkins.
- Click on Configure Global Security
- Check the Enable Security check box
- Under Security Realm, select Jenkins’ own user database
- In the Authorization section, select Logged-in users can do anything.
- Unselect Allow anonymous read access.
- Click Save to save your changes.
Create New Jenkins Admin User
Once you have completed the tasks above, you will be redirect to a page where a new Admin user can be created. Fill in your new details and then click Create First Admin User.
You have no created a new Admin user with a new password.
Conclusion
Reseting the admin’s password is not a simple process. It also exposes us to dangers by disabling user logins, allowing anonymous users full control over the Jenkins server.
This tutorial showed you how to reset the admin password by removing the current account, and then recreating it. A better solution would be to have multiple admins, where possible, and have another admin reset the password.
How to Reset Jenkins Admin User Password
Jenkins is a popular open-source automation server that is widely used for continuous integration and continuous delivery (CI/CD) in software development. As a system administrator, you may need to reset the Jenkins admin password if you have lost or forgotten it.
In this tutorial, we will learn how to reset the Jenkins admin password in a few simple steps.
Steps to Reset Jenkins Admin Password
Follow the below steps to recover admin account access to the Jenkins portal.
- Disable Current Security – First of all, login to your Jenkins server and edit the Jenkins configuration file (/var/lib/jenkins/config.xml) in your favorite text editor:
sudo vim /var/lib/jenkins/config.xml
Disable the security by changing the `useSecurity` tag value to “false”. Save your file and close it. The vim users press the `ESC` button then type `:wq!` and hit Enter to save the file.
Apply Changes – Restart Jenkins service to apply the changes.
sudo systemctl restart jenkins
After restarting make sure the Jenkins service is running with `sudo systemctl status jenkins` command.
- Enable the “Enable Security” option.
- In Security Realm option select “Jenkins own database”
- Make sure to uncheck the “Allow users to sign up” option under the “Jenkins own database” option.
Conclusion
In this tutorial, we learned how to reset the Jenkins admin password in a few simple steps. We hope that this tutorial has helped you understand how to reset the Jenkins admin password and that you are now able to access your Jenkins instance. If you have any questions or need further assistance, please don’t hesitate to ask.
Jenkins: Reset Admin Password
If you have forgotten the Jenkins admin password and can’t log in to a Jenkins user interface (UI) as administrator, you can connect to a Jenkins server via SSH and reset the Jenkins admin password.
The simplest solution is to completely disable security in /var/lib/jenkins/config.xml file, access the Jenkins UI omitting authentication and rest the Jenkins admin password.
Cool Tip: Jenkins Username & Password by Default! Read more →
Reset Jenkins Admin Password
Make a backup copy of a Jenkins config file (this step is important as after resetting the Jenkins admin password we would need to restore the previous settings):
$ cp /var/lib/jenkins/config.xml /var/lib/jenkins/config.xml.back
Open the config file /var/lib/jenkins/config.xml and disable the security:
Restart the Jenkins service:
$ systemctl restart jenkins
Go to the Jenkins UI (you won’t be asked for any credentials this time) and reset the admin password:
- Navigate to «Manage Jenkins» -> «Security» -> «Configure Global Security» -> «Authentication»
- Select the «Security Realm» (e.g. «Jenkins’ own user database» ) and click on «Save»
- Go to «People» -> Click on a username for which you want to change the password (e.g. admin ) -> «Configure» -> Enter a new password in the «Password» and «Confirm password» fields and click on «Save»
Once the admin password is reset, restore the previous /var/lib/jenkins/config.xml file and restart Jenkins:
$ mv /var/lib/jenkins/config.xml.back /var/lib/jenkins/config.xml $ systemctl restart jenkins