Unable to login to jenkins even if we enter valid credential

Unable to login to jenkins even if we enter valid credential

You can change the password by manually editing the configuration file for your user. (/jenkins/users/username/config.xml) and update the contents of passwordHash:
<passwordHash>#jbcrypt:$2a$10$razd3L1aXndFfBNHO95aj.IVrFydsxkcQCcLmujmFQzll3hcUrY7S</passwordHash>
Restart Jenkins and login using below password:
test
Have a look at below thread: Reset Jenkins Configuration Command Line
With the limited information you have provided, i think you were pressing wrong credentials. However, i know of 2 options to fix this :
1) Go to your Jenkins installation Directory (Usually C:\Users\<UserID>\.jenkins\), look for config.xml - Check for below xml tags
useSecurity authorizationStrategy. You can play around with the values to get anonymous access/allow signup etc..
2) Re-install the jenkins itself - Remember to backup your jobs/workspace if you have already coded some jobs.
In case , you are installing as Jenkins as a 'Windows service' , then you can use username: admin & initial password: 'provided while installing Jenkins' to log in.
In addition to this answer, I had to do restart the Jenkins service for the change to take effect:
Go to the config folder (seems to be in one of the following for different versions):
# Windows (my machine)
C:\Users\<user>\AppData\Local\Jenkins\.jenkins\users\<jenkins username>_<random numbers>\config.xml
# Windows (Other)
C:\ProgramData\Jenkins\.jenkins\config.xml
# Linux
/jenkins/users/username/config.xml
# (Others?...)
Change contents of passwordHash tag for this:
<passwordHash>#jbcrypt:$2a$10$razd3L1aXndFfBNHO95aj.IVrFydsxkcQCcLmujmFQzll3hcUrY7S</passwordHash>
Restart Jenkins service:
# Windows
# (Inside Jenkins folder: C:\Program Files\Jenkins)
jenkins.exe restart
# Linux
sudo service jenkins restart
Login using your username and the password:
test
In mycase after commenting or removing the below line, it worked!
Goto: C:\ProgramData\Jenkins.jenkins\config.xml
Remove the below line in config.xml: enter image description here
While solving same issue, I noticed there were two folders .Jenkins in my system.
That's why attempts to change config.xml failed for me.
For version 2.401.2 it was ProgramData\Jenkins\.Jenkins (not that one in {your_user} folder).
Hope this saves somebody's time