
步骤一:修改配置文件
找到Jenkins下的config.xml文件,如下例子,采用的是Tomcat+Jenkins.war包部署后,会在root目录下,有一个隐藏的.jenkins目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| [root@lvjing ~]# ls -al 总用量 222716 dr-xr-x---. 26 root root 4096 3月 30 14:50 . dr-xr-xr-x. 17 root root 244 5月 18 2022 .. -rw------- 1 root root 16048 3月 29 16:55 .bash_history -rw-r--r--. 1 root root 18 5月 11 2019 .bash_logout -rw-r--r--. 1 root root 176 5月 11 2019 .bash_profile -rw-r--r--. 1 root root 176 5月 11 2019 .bashrc drwx------ 4 root root 28 4月 12 2021 .cache drwxr-x--- 4 root root 32 4月 20 2021 .config -rw-r--r--. 1 root root 100 5月 11 2019 .cshrc drwx------ 2 root root 25 6月 13 2022 .docker drwxr-x--- 15 root root 4096 3月 30 16:13 .jenkins drwxr-xr-x 3 root root 24 4月 12 2021 .m2 ...
|
进入到.jenkins目录,就能找到config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| [root@lvjing .jenkins]# ls caches nodeMonitors.xml config.xml nodes credentials.xml org.jenkinsci.plugins.docker.commons.tools.DockerTool.xml fingerprints org.jenkinsci.plugins.gitclient.JGitApacheTool.xml hudson.model.UpdateCenter.xml org.jenkinsci.plugins.gitclient.JGitTool.xml hudson.plugins.git.GitTool.xml org.jenkinsci.plugins.workflow.flow.FlowExecutionList.xml hudson.plugins.gradle.Gradle.xml plugins hudson.tasks.Ant.xml queue.xml hudson.tasks.Maven.xml queue.xml.bak identity.key.enc ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation.xml jenkins.install.InstallUtil.lastExecVersion secret.key jenkins.install.UpgradeWizard.state secret.key.not-so-secret jenkins.model.JenkinsLocationConfiguration.xml secrets jenkins.mvn.GlobalMavenConfig.xml tools jenkins.security.apitoken.ApiTokenPropertyConfiguration.xml updates jenkins.security.QueueItemAuthenticatorConfiguration.xml userContent jenkins.security.UpdateSiteWarningsConfiguration.xml users jenkins.telemetry.Correlator.xml workflow-libs jobs workspace logs
|
编辑config.xml文档,将对应的内容修改如下
1 2 3 4 5 6 7 8
| <useSecurity>true</useSecurity> <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy"> <denyAnonymousReadAccess>true</denyAnonymousReadAccess> </authorizationStrategy> <securityRealm class="hudson.security.HudsonPrivateSecurityRealm"> <disableSignup>true</disableSignup> <enableCaptcha>false</enableCaptcha> </securityRealm>
|
重启Jenkins
步骤二:进入Jenkins页面进行配置
这时候,打开Jenkins页面,就会发现,不需要任何认证,就能看到Jenkins内容了,下面进行具体操作:
进入Manage Jenkins

进入Configure Global Security

“安全域”选择“Jenkins’ own user database”

点击【保存】
步骤三:管理用户,进行密码修改
重新进入系统管理页面,此时会发现“安全”内,出现了“管理用户”

点击进入后,展示“用户列表”,选择用户

进入具体用户界面,点击【设置】进行密码修改

进入页面后,页面向下滑动,到“Password”处,输入新的密码

点击【保存】,使用新的密码进行登录