It might happen while configuring security realm / authorization, your admin account may be locked out and you are no longer able to reconfigure Jenkins.
When this happens, you can fix this by the following steps:
- Stop Jenkins (the easiest way to do this is to kill the servlet container.)
- Go to $JENKINS_HOME in the file system and find config.xml file.
- Open this file in the editor.
- Look for the false element in this file.
- Replace true with false
- Remove the elements authorizationStrategy and securityRealm
- Start Jenkins
When Jenkins comes back, it’s in the unsecured mode where everyone gets full access to the system. Now fix the issue and re-enable the elements for authorizationStrategy and securityRealm.
If this is still not working, trying renaming or deleting config.xml.
4 thoughts on “Disable security in Jenkins to recover admin user”
I think you forgot to mention that `useSecurity` has to be changed from `true` to `false`
I accidentally deleted the admin role now i am running in anonymous. But How to re-enable the admin based login
Best idea would be to compare config file from a working server and edit config file manually to add the role
You saved my life bro.. Important presentation and this issue which was solved by your solution happened.. God bless!!