首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven未授权,ReasonPhrase:未经授权

Maven未授权,ReasonPhrase:未经授权
EN

Stack Overflow用户
提问于 2015-08-20 13:26:08
回答 3查看 36.3K关注 0票数 5

我试图从Nexus存储库中检出我的代码。首先,我用

代码语言:javascript
复制
mvn --encrypt-master-password _mypassword_

这是我的c:/Users/joanet/.m2/sets-security.xml:

代码语言:javascript
复制
<settingsSecurity>
<master>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED2ws=}</master>
</settingsSecurity>

这是我的c:/progs/PGM/apache-maven-3.0.5/conf/settings.xml

代码语言:javascript
复制
  <?xml version="1.0" encoding="UTF-8"?>

    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
    license agreements. See the NOTICE file distributed with this work for additional
    information regarding copyright ownership. The ASF licenses this file to
    you under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
    by applicable law or agreed to in writing, software distributed under the
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
    OF ANY KIND, either express or implied. See the License for the specific
    language governing permissions and limitations under the License. -->

    <!-- http://maven.apache.org/settings.html -->
    <settings xmlns="http://maven.apache.org/settings/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <localRepository>C:/Users/joanet/.m2/repository</localRepository>


    <proxies>
     <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>joanet</username>
      <password>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED5ws=}</password>
      <host>157.129.133.11</host>
      <port>8032</port>
      <nonProxyHosts>localhost</nonProxyHosts>
     </proxy>
    </proxies>

    <servers>
      <server>
       <id>ecPublicRepository</id>
       <username>joanet</username>
       <password>{TnRCVc3cX6MH5qRXEMLwxjKGfXQu6v/6wR0rgHED5ws=}</password>
      </server>


    </servers>

    <mirrors></mirrors>

    <pluginGroups>
     <!-- pluginGroup Specifies a further group identifier to use for plugin lookup.  -->
     <pluginGroup>com.oracle.weblogic</pluginGroup>
     <pluginGroup>com.github.searls</pluginGroup>
     <pluginGroup>com.cj.jshintmojo</pluginGroup>
     <pluginGroup>com.github.phasebash</pluginGroup>

    </pluginGroups>

    <profiles>
     <profile>
      <id>activeProfile</id>

      <repositories>

       <repository>
          <id>ecPublicRepository</id>
          <url>https://foo.com/nexus/content/groups/public/</url>
       </repository>


      </repositories>

      <pluginRepositories>

       <pluginRepository>
        <id>PublicRepository</id>
        <name>Public Repository</name>
        <url>https://foo.com/nexus/content/groups/public/</url>
       </pluginRepository>
      </pluginRepositories>

     </profile>

    </profiles>

    <!-- activeProfiles | List of profiles that are active for all builds. | -->
    <activeProfiles>
     <activeProfile>activeProfile</activeProfile>
    </activeProfiles>


    </settings>

但这是一个错误:

代码语言:javascript
复制
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not
 transfer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.3.1 from/
to ecPublicRepository (https://foo.com/nexus/content/groups/public/): Not authorized , ReasonPhrase:Unauthorized.
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
facts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
fact(DefaultArtifactResolver.java:193)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:281)
        ... 28 more
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-08-20 13:33:57

加密主密码之后,还应该加密nexus所需的实际密码。因此,settings-security.xml中的散列值应该不同于在服务器配置中使用的实际值。

您可以遵循以下步骤(取自这里):

使用以下命令行: mvn -加密-主密码 注意:因为Maven 3.2.1密码是一个可选参数。如果没有提供,Maven将提示输入密码。早期版本的Maven不会提示输入密码,因此必须在命令行上输入明文。有关更多信息,请参见下面的提示。 此命令将生成密码的加密版本,如下所示 {jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=} 将此密码存储在~/.m2/sets-security.xml中;它应该如下所示 {jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=} 这样做后,您可以开始加密现有的服务器密码。如何加密服务器密码 您必须使用以下命令行: 加密密码 注意:就像--加密-主密码一样,密码参数是可选的,因为Maven 3.2.1。 此命令将生成它的加密版本,类似于 {COQLCE6DU6GtcS5P=} 将其粘贴到服务器部分的settings.xml文件中。这将看起来像: ...my.server foo {COQLCE6DU6GtcS5P=} . 请注意,密码可以包含花括号外的任何信息,以便下列内容仍然有效:

票数 12
EN

Stack Overflow用户

发布于 2019-03-04 16:11:25

在为Nexus更改密码时,我遇到了一个奇怪的问题,按照以上回答中同样描述的密码加密过程。

它不起作用,每次都会出现Could not transfer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.3.1 from/to ecPublicRepository (https://mynexusrepo/nexus/content/groups/public/): Not authorized , ReasonPhrase:Unauthorized.错误。

我又重新做了一遍,假设我在密码中做了一个愚蠢的错误即使尝试将密码临时设置为明文(没有加密),也会导致同样的错误。

最后,Maven似乎可以使用我的当前密码进行身份验证。我的新密码中包含一个e(“é”),在我看来,Maven无法正确使用它。它很可能与其他字符相同,如à,à,as,as,等等.

我重新设置我的密码,使用几乎相同的密码,但没有那样的字符,一切都恢复正常。同时,我一直能够正确登录到Nexus,通过网络接口。

票数 1
EN

Stack Overflow用户

发布于 2016-09-16 21:42:49

在我的例子中,我的问题是我复制了maven ~/.m2/setings.xml文件,该文件本身指定了“用户名和密码”,但没有意识到,如果这样做,如果还存在文件安全性-setings.xml,您也需要复制该文件(它是双哈希):sscc=t

我的预感/假设是,如果没有安全设置s.xml文件,maven很高兴地使用来自settings.xml的密码,而不是对它们进行双重哈希,从而将它们错误地呈现给服务器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32119545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档