You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Harbor v2.1.0修改Admin密码后登录异常求助

问题描述
  1. 在Harbor v2.1.0的WEB UI中修改了admin密码;
  2. 登录时出现异常,同时出现“Login Succeeded”和“unauthorized: authentication required”的提示,CLI日志如下:
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://harbor.miduchina.com/v2/: unauthorized: authentication required
  1. core.log中出现多次认证失败错误,日志如下:
Feb 27 10:26:40 172.20.0.1 core[1682]: 2023-02-27T02:26:40Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="ac22b544-ec79-4b1a-82fc-b6e9275769ca"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:26:42 172.20.0.1 core[1682]: 2023-02-27T02:26:42Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="2312bec3-b450-4553-903b-b2de4e94b0e5"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:26:55 172.20.0.1 core[1682]: 2023-02-27T02:26:55Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="fffae489-8b41-458b-8ea8-ae3d412ac86f"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:27:08 172.20.0.1 core[1682]: 2023-02-27T02:27:08Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="b7e0678b-59cd-4574-80eb-61880b12335e"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:27:20 172.20.0.1 core[1682]: 2023-02-27T02:27:20Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="e951b2e1-ea41-4fdd-890a-d8371dca8ea3"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:27:25 172.20.0.1 core[1682]: 2023-02-27T02:27:25Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="fb78e6b7-a228-4660-9d89-ba2f626f87dd"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
Feb 27 10:27:40 172.20.0.1 core[1682]: 2023-02-27T02:27:40Z [ERROR] [/server/middleware/security/basic_auth.go:41][requestID="ff5603c5-6d4f-4b32-b9d7-fb267fe70771"]: failed to authenticate admin: Failed to authenticate user, due to error 'Invalid credentials'
解决方案

1. 清理Docker客户端认证缓存

  • 执行docker logout harbor.miduchina.com清除本地旧认证信息
  • 删除/root/.docker/config.json中对应Harbor地址的认证条目,或直接备份后删除该文件(重新登录会自动生成)
  • 用新密码重新登录,建议使用安全的--password-stdin方式:
    echo "你的新密码" | docker login harbor.miduchina.com -u admin --password-stdin
    

2. 重启Harbor所有组件

Harbor v2.1.0修改密码后,部分组件可能未同步新密码,需重启服务:

  • 进入Harbor安装目录(默认是/usr/local/harbor)
  • 执行docker-compose down停止所有服务
  • 执行docker-compose up -d启动所有服务
  • 等待1-2分钟,让组件完成初始化与密码同步

3. 验证数据库中admin密码状态(可选)

若重启后问题依旧,可检查数据库密码是否正确更新:

  • 进入Harbor数据库容器:docker exec -it harbor-db bash
  • 登录PostgreSQL:psql -U postgres
  • 切换到Harbor数据库:\c registry
  • 查询admin用户密码哈希:SELECT username, password FROM harbor_user WHERE username='admin';
  • 确认哈希对应新密码,若未更新,可在WEB UI再次修改密码后重新查询

4. 验证服务状态

重启后查看core.log是否还有认证失败错误:

docker logs harbor-core | grep "failed to authenticate admin"

若日志无错误,重新尝试Docker登录即可。

内容的提问来源于stack exchange,提问作者junjie lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 09:00:41