这篇文章上次修改于 504 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

容器存储卷初始化问题

Harbor采用PostgreSQL和Redis作为数据库,在Bitnami提供的默认Helm Chart里并未提供初始化PostgreSQL和Redis的方法,直接使用内置的容器可能会导致部署失败,建议先行手动部署Bitnami提供的Redis和PostgreSQL,再将其连接信息填入Harbor的Helm Chart文件。

密码重置问题

如果忘了密码,可以先用NodePort方式将PostgreSQL服务暴露到内网,连接上去之后,先切换到Harbor Registry数据库再操作:

update harbor_user set password='a71a7d0df981a61cbb53a97ed8d78f3e',salt='ah3fdh5b7yxepalg9z45bu8zb36sszmr' where username='admin';

如此操作即可登录。

SQL Salt算法问题

密码重置后还是无法登录,查看容器日志发现:

 2022-08-02T00:28:44Z [DEBUG] [/server/middleware/artifactinfo/artifact_info.go:53]: In artifact info middleware, url: /c/login

 2022-08-02T00:28:44Z [DEBUG] [/server/middleware/security/unauthorized.go:28][requestID="4ad2ec2686ff0884ff4efbfad2d08371"]: an unauthorized security context generated for request POST /c/login

 2022-08-02T00:28:44Z [DEBUG] [/core/auth/authenticator.go:145]: Current AUTH_MODE is db_auth

 2022-08-02T00:28:44Z [DEBUG] [/core/auth/authenticator.go:158]: Login failed, locking admin, and sleep for 1.5s

 2022-08-02T00:28:46Z [ERROR] [/core/controllers/base.go:103]: Error occurred in UserLogin: Failed to authenticate user, due to error 'Invalid credentials'

提取关键错误信息: 'Invalid credentials'
经查该问题系数据库Salt算法有误所致,更改其算法即可解决:

update harbor_user set password_version='sha1' where user_id=1;