jenkins忘记密码了怎么办-jenkins找回密码

一段时间没登录jenkins,可能把密码忘记了,再登录时总是提示:登录信息无效。请重试。If you are a system administrator and suspect this to be a configuration problem, see the server console output for more details.应该是密码或者账号不对了。怎么找回密码呢,只能去配置文件中修改了

    首先找到jenkins的目录:-DJENKINS_HOME=/var/lib/jenkins

    此目录下会有一个users文件夹(jenkins/users/admin),存放着各登录用户的账号信息,一个用户账户一个文件夹。文件夹里有配置文件:config.xml,内容如下:

<?xml version='1.0' encoding='UTF-8'?>
<user>
  <fullName>admin</fullName>
  <description>总管理员账号</description>
  <properties>
    <jenkins.security.ApiTokenProperty>
      <apiToken>rWArknUk9PnLS7riVJGISU/HFkjErmpNNNuiDC31aFd0SjdAh0ih3tN8GDkC94Nm</apiToken>
    </jenkins.security.ApiTokenProperty>
    <jenkins.security.LastGrantedAuthoritiesProperty>
      <roles>
        <string>authenticated</string>
      </roles>
      <timestamp>1475071638132</timestamp>
    </jenkins.security.LastGrantedAuthoritiesProperty>
    <hudson.model.MyViewsProperty>
      <primaryViewName></primaryViewName>
      <views>
        <hudson.model.AllView>
          <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
          <name>All</name>
          <filterExecutors>false</filterExecutors>
          <filterQueue>false</filterQueue>
          <properties class="hudson.model.View$PropertyList"/>
        </hudson.model.AllView>
      </views>
    </hudson.model.MyViewsProperty>
    <hudson.model.PaneStatusProperties>
      <collapsed/>
    </hudson.model.PaneStatusProperties>
    <hudson.security.HudsonPrivateSecurityRealm_-Details>
      <passwordHash>#jbcrypt:$2a$10$NqPv3NpgxkpQi/ffEsEkhuMZYpbKc5cVVrP60cD6MX5IujYkLlOGm</passwordHash>
    </hudson.security.HudsonPrivateSecurityRealm_-Details>
    <org.jenkinsci.main.modules.cli.auth.ssh.UserPropertyImpl>
      <authorizedKeys></authorizedKeys>
    </org.jenkinsci.main.modules.cli.auth.ssh.UserPropertyImpl>
    <hudson.search.UserSearchProperty>
      <insensitiveSearch>false</insensitiveSearch>
    </hudson.search.UserSearchProperty>
  </properties>
</user>

如上面的配置文件,把passwordHash改成上面的值(对应密码是123456),账户就是这个文件夹的名称,改好后登录jenkins,在管理平台上修改密码即可。

原文地址:https://www.cnblogs.com/wsy0202/p/13154487.html