首页 > 解决方案 > 将包上传到 Nexus 时出现随机“401 Unauthorized”错误

问题描述

我正在使用 curl 命令将包上传到 Nexus Repo Manager:

例如:

curl -v -u mvn-deploy:password -T a.ear https://nexus.url:8443/repository/release/group/a/12.0.1/a-12.0.1.jar

该命令有时可以正常工作,但有时会因“401 Unauthorized”错误而失败。这让我很困扰,因为失败似乎很随机。使用 Maven 时,我也可以看到相同的随机“401”错误。

这是 curl 的输出:

* Server auth using Basic with user 'mvn-deploy'
> PUT /a.jar HTTP/1.1
> Authorization: Basic bXZuLWRlcGxveTppTXV4UkZDQTQ1TFkzcFQ0S0U3QVB3T2VoZ0o0c0tFLWVVdm5ZRzF6c1NnVw==
> User-Agent: curl/7.29.0
> Host: nexus.url:8443
> Accept: */*
> Content-Length: 74538424
> Expect: 100-continue
> 
< HTTP/1.1 401 Unauthorized
< Date: Mon, 31 May 2021 12:55:14 GMT
< Strict-Transport-Security: max-age=7776000
< Server: Nexus/3.29.2-02 (PRO)
< X-Content-Type-Options: nosniff
* Authentication problem. Ignoring this.
< WWW-Authenticate: BASIC realm="Sonatype Nexus Repository Manager"
< Connection: close
< 
{ [data not shown]

标签: authenticationnexus3

解决方案


推荐阅读