Jenkins 配置文件存放在用户目录下.jenkins中
例如root用户在路径 /root/.jenkins/
其他用户在 /home/user/.jenkins/
cd /root/.jenkins/
在 .jenkins目录下有一个user目录,存放用户信息
cd user
user目录下找到你的帐号目录,例如你的登录帐号是zsg,那么目录就是zsg
cd zsg
该目录下有个config.xml文件
<?xml version='1.0' encoding='UTF-8'?>
<user>
<fullName>zsg</fullName>
<properties>
<jenkins.security.ApiTokenProperty>
<apiToken>{AQAAABAAAAAwkHqAK0qH+cu7RzN61SETzoeyKHGmO5fEEeNVBRMC2pWLMUGqAaqTWtuCP2MwqhR2j4HgtlemMg0Jv4Gd0QgBpQ==}</apiToken>
</jenkins.security.ApiTokenProperty>
<com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty plugin="credentials@2.1.14">
<domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash"/>
</com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty>
<hudson.plugins.emailext.watching.EmailExtWatchAction_-UserProperty plugin="email-ext@2.58">
<triggers/>
</hudson.plugins.emailext.watching.EmailExtWatchAction_-UserProperty>
<hudson.model.MyViewsProperty>
<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>
<org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty plugin="display-url-api@2.0">
<providerId>default</providerId>
</org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty>
<hudson.model.PaneStatusProperties>
<collapsed/>
</hudson.model.PaneStatusProperties>
<hudson.search.UserSearchProperty>
<insensitiveSearch>true</insensitiveSearch>
</hudson.search.UserSearchProperty>
<hudson.security.HudsonPrivateSecurityRealm_-Details>
<passwordHash>#jbcrypt:$2a$10$.pJzYCexOznAMj9z469veezP1Z.RYfFng2WBHWXtCQWkpiN.EScla</passwordHash>
</hudson.security.HudsonPrivateSecurityRealm_-Details>
<hudson.tasks.Mailer_-UserProperty plugin="mailer@1.20">
<emailAddress>zsg88@163.com</emailAddress>
</hudson.tasks.Mailer_-UserProperty>
<jenkins.security.LastGrantedAuthoritiesProperty>
<roles>
<string>authenticated</string>
</roles>
<timestamp>1500396088955</timestamp>
</jenkins.security.LastGrantedAuthoritiesProperty>
</properties>
passwordHash 字段存放的是加密过后的密码
Jenkins的密码采用的是Java加解密工具 jBCrypt,我也是第一次接触到这种加密方式,实在被他惊叹到了!这种加密方式每次加密同一个明文竟然都是得到不一样的结果,那他又是通过怎样的方式来解密的呢?原来,他拿着用户的明文,和存储的密文去重新生成一串密文去判断。总结如下,它有以下特点:
关于bcrypt:
1、bcrypt是不可逆的加密算法,无法通过解密密文得到明文。
2、bcrypt和其他对称或非对称加密方式不同的是,不是直接解密得到明文,也不是二次加密比较密文,而是把明文和存储的密文一块运算得到另一个密文,如果这两个密文相同则验证成功。
3、对于同一个明文的加密结果一般不同。
附上Java源码
import org.mindrot.jbcrypt.BCrypt;
public class Test
{
public static void main(String[] args)
{
String password = "abcd123"
//加密后的字符串
String hashed = BCrypt.hashpw(password, BCrypt.gensalt());
System.out.println(hashed);
//检查
if (BCrypt.checkpw(password, hashed))
System.out.println("匹配成功");
else
System.out.println("匹配失败");
}
}
将加密后的字符串替换到config.xml里的passwordHash信息,重启tomcat