maven私服nexus忘记密码,解决方法(转载)

转载:https://jingyan.baidu.com/article/c45ad29c1e1b0d051753e219.html
注意:方法前提是能够登录linux服务器;

方式一:

(1)找到nexus的程序路径和Maven仓库路径:

nexus-2.14.2-01 目录为程序路径,里面有 logs、bin、conf、tmp 等目录 
sonatype-work   目录为Maven仓库路径

(2)在Maven仓库路径下有一个文件security.xml,文件中有用户和密码以及权限的分配:

sonatype-work/nexus/conf/security.xml


<security>
  <version>2.0.5version>
  <users>
    <user>
      <id>deploymentid>
      <firstName>DeploymentfirstName>
      <lastName>UserlastName>
      <password>b2a0e378437817cebdf753d7dff3dd75483af9e0password>
      <status>activestatus>
      <email>[email protected]email>
    user>
    <user>
      <id>anonymousid>
      <firstName>NexusfirstName>
      <lastName>Anonymous UserlastName>
      <password>$shiro1$SHA-512$1024$Q82OUH8KmDZZrXTOpZY+lg==$Tsscq7Su4ZZDtUV9cKrAbJK7UIMFtxRdN/UUDBpJtdRegcIWUEAEqbYarhKm7znytB8X8Mlu68dc82IHqUBX/g==password>
      <status>activestatus>
      <email>[email protected]email>
    user>
    <user>
      <id>adminid>
      <firstName>AdministratorfirstName>
      <lastName>UserlastName>
      <password>$shiro1$SHA-512$1024$PWSCGOcz9yPs7g7d6gkAcQ==$m1hRsx948wkmFtyb/d/brugEgPIt88dz7UlvqXiiI9d5sTRwPX7VCyljEz34Uxl3nQ+Y7KCESnsJkpSt9DnHZg==password>
      <status>activestatus>
      <email>[email protected]email>
    user>
    <user>
      <id>rootid>
      <firstName>rootfirstName>
      <lastName>rootlastName>
      <password>$shiro1$SHA-512$1024$d9ZrWi5Pu9XT0E2CTia1kQ==$cGhEosVMqVxfqZCfV9ZXax6o/fGzWvt1LXnB5qiCbhJFnL1r7BSpVsHKncc3FoKb/KjQvuYEnqtT/wWkYEvtyA==password>
      <status>activestatus>
      <email>[email protected]email>
    user>
  users>
  <userRoleMappings>
    <userRoleMapping>
      <userId>deploymentuserId>
      <source>defaultsource>
      <roles>
        <role>nx-deploymentrole>
        <role>repository-any-fullrole>
      roles>
    userRoleMapping>
    <userRoleMapping>
      <userId>anonymoususerId>
      <source>defaultsource>
      <roles>
        <role>anonymousrole>
        <role>repository-any-readrole>
      roles>
    userRoleMapping>
    <userRoleMapping>
      <userId>adminuserId>
      <source>defaultsource>
      <roles>
        <role>nx-adminrole>
      roles>
    userRoleMapping>
    <userRoleMapping>
      <userId>rootuserId>
      <source>defaultsource>
      <roles>
        <role>nx-deploymentrole>
        <role>repository-any-fullrole>
      roles>
    userRoleMapping>
  userRoleMappings>
security>

(3)将忘记密码的用户的password节点信息用f865b53623b121fd34ee5426c792e5c33af8c227字符串替换,这样密码就重置为admin123;
(4)找到nexus的程序路径nexus的bin目录,重启nexus服务./nexus restart,重启完成之后admin用户的密码就重置成了admin123了;


方式二:
我们还可以通过修改用户角色来获取管理员权限,然后通过匿名用户修改管理员密码,还是修改security.xml文件,找到anonymous的权限配置节点,修改其角色权限,添加用户管理员权限:
nx-admin
然后重启nexus服务,这个时候打开nexus前端页面,在没有登录的情况下,发现之前看不到的菜单都可以看到了。和管理员登录状态下看到的一样,在页面选择security菜单的users,重置密码,密码设置之后,再把上面添加的节点nx-admin
删除,再重启服务;
第二种方法给匿名用户添加的nx-admin,在修改完密码之后一定要把刚刚添加的角色删除,再重启,否则任何人都可以修改nexus服务器配置和文件了

你可能感兴趣的:(maven,nexus,linux)