This post describes you If you forgot the admin password of Jenkins how to reset the password without affecting the production environment. We have an easy way to reset that user password in config.xml file.  Generate Hash password for the Jenkins admin user using sha256sum command, so I Used sha256sum command create a password cryptographic hash such as SHA-256 allow for authentication of data obtained from insecure mirrors. The command is,

$ sudo echo -n 'Your_Password{admin}' | sha256sum

f1d00b085d3eba6a28240ebeb2dd570f427677bca084d2d8e452ae0728678d4b  -  

By default the admin config.xml file is available in /var/lib/jenkins/users/admin/config.xml, 

so lets configure <PasswordHash> replace the exisiting one using sed command,Set the format like, 


$ sudo sed -i 's/#jbcrypt:$2a$10$OkOb299eLePgWeGw8SjWQ.CD2l2CDo4R6SphcMucxp5CWXM24eskq/admin:f1d00b085d3eba6a28240ebeb2dd570f427677bca084d2d8e452ae0728678d4b/g' config.xml  

Once you have executed the above command need to restart the Jenkins using the commands below, If you are using the Jenkins in your machine directly execute this command,

$ sudo sudo service jenkins restart

If the Jenkins is running in your docker container just stop and start the service,

docker container stop jenkins_container_name or container_ID
docker container start jenkins_container_name  or container_ID