[英]Recover Jenkins username and password
how can we reset the username and password in windows for Jenkins.我们如何为 Jenkins 重置 windows 中的用户名和密码。 or is there a way to uninstall Jenkins completely so that when I reinstall it, I can again create a username and password?
或者有没有办法完全卸载 Jenkins,这样当我重新安装它时,我可以再次创建用户名和密码?
Any solutions would be very much appreciated任何解决方案将不胜感激
You can simply delete the entire JENKINS_HOME directory and then restart the server.您可以简单地删除整个 JENKINS_HOME 目录,然后重新启动服务器。 This will prompt you to the new setup wizard.
这将提示您进入新的设置向导。
Open JENKINS_HOME/config.xml and disable security by setting the following.打开 JENKINS_HOME/config.xml 并通过设置以下内容禁用安全性。
<useSecurity>false</useSecurity>
Then access Jenkins and open the Script Console
(JENKINS_URL/script).然后访问 Jenkins 并打开
Script Console
(JENKINS_URL/script)。 Execute the following script to create a new user.执行以下脚本来创建一个新用户。
import jenkins.model.*
import hudson.security.*
def j = Jenkins.getInstance()
def realm = new HudsonPrivateSecurityRealm(false)
realm.createAccount("newadmin","newpass")
j.setSecurityRealm(realm)
j.save()
Now enable security again and login to Jenkins with the new user.现在再次启用安全性并使用新用户登录 Jenkins。
Additional额外的
If you want to recover the old user.如果要恢复旧用户。 After following the above steps open the file
JENKINS_HOME/users/newadmin_RANDOM_NUMBER/config.xml
and copy the following two values seed
and passwordHash
to the old admins config.xml(If the old admins username is admin
the file should be located at JENKINS_HOME/users/admin_RANDOM_NUMBER/config.xml
)按照上述步骤打开文件
JENKINS_HOME/users/newadmin_RANDOM_NUMBER/config.xml
并将以下两个值seed
和passwordHash
复制到旧管理员 config.xml(如果旧管理员用户名是admin
,则该文件应位于JENKINS_HOME/users/admin_RANDOM_NUMBER/config.xml
)
<jenkins.security.seed.UserSeedProperty>
<seed>405397d771ce33e7</seed>
</jenkins.security.seed.UserSeedProperty>
and
<hudson.security.HudsonPrivateSecurityRealm_-Details>
<passwordHash>#jbcrypt:$2a$10$UGYgHccQxAd9V6neqfJxx.......</passwordHash>
</hudson.security.HudsonPrivateSecurityRealm_-Details>
Then restart the server and you should be able to use the password of newadmin
for admin
.然后重新启动服务器,您应该可以将
newadmin
的密码用于admin
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.