harbor重置密码
今天遇到了一个问题,harbor的管理员密码失效了,那如何重置harbor的密码呢
这里以docker部署的harbor为例
找到数据对应的容器
docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
harbor-core goharbor/harbor-core:v2.12.1 "/harbor/entrypoint.…" core 2 hours ago Up 2 hours (healthy)
harbor-db goharbor/harbor-db:v2.12.1 "/docker-entrypoint.…" postgresql 2 hours ago Up 2 hours (healthy)
harbor-exporter goharbor/harbor-exporter:v2.12.1 "/harbor/entrypoint.…" exporter 2 hours ago Up 2 hours
harbor-jobservice goharbor/harbor-jobservice:v2.12.1 "/harbor/entrypoint.…" jobservice 2 hours ago Up 2 hours (healthy)
harbor-log goharbor/harbor-log:v2.12.1 "/bin/sh -c /usr/loc…" log 2 hours ago Up 2 hours (healthy) 127.0.0.1:1514->10514/tcp
harbor-portal goharbor/harbor-portal:v2.12.1 "nginx -g 'daemon of…" portal 2 hours ago Up 2 hours (healthy)
nginx goharbor/nginx-photon:v2.12.1 "nginx -g 'daemon of…" proxy 2 hours ago Up 2 hours (healthy) 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp, 0.0.0.0:10080->8080/tcp, [::]:10080->8080/tcp, 0.0.0.0:10000->8443/tcp, [::]:10000->8443/tcp
redis goharbor/redis-photon:v2.12.1 "redis-server /etc/r…" redis 2 hours ago Up 2 hours (healthy)
registry goharbor/registry-photon:v2.12.1 "/home/harbor/entryp…" registry 2 hours ago Up 2 hours (healthy)
registryctl goharbor/harbor-registryctl:v2.12.1 "/home/harbor/start.…" registryctl 2 hours ago Up 2 hours (healthy)
trivy-adapter goharbor/trivy-adapter-photon:v2.12.1 "/home/scanner/entry…" trivy-adapter 2 hours ago Up 2 hours (healthy)
进入容器
docker exec -it harbor-db bash
进入数据库
psql -U postgres
查看数据库
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
registry | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
(4 rows)
进入registry 数据库
postgres=# \c registry
You are now connected to database "registry" as user "postgres".
查看所有用户
registry=# select * from harbor_user;
user_id | username | email | password | realname | comment | deleted | reset_uuid | salt | sysadmin_flag | creation_time | update_time | password_version
---------+-----------+-------+----------------------------------+----------------+----------------+---------+------------+----------------------------------+---------------+----------------------------+----------------------------+------------------
2 | anonymous | | | anonymous user | anonymous user | t | | | f | 2025-01-15 03:28:49.478067 | 2025-01-15 03:28:50.225759 | sha1
1 | admin | | 15a7243ccc7babd94f55d1de59870194 | system admin | admin user | f | | ev5RBNpEEPQgQaefgkFgIv0lWrt288Tr | t | 2025-01-15 03:28:49.478067 | 2025-01-15 03:28:50.682201 | sha256
(2 rows)
清空密码
update harbor_user set salt='', password='' where user_id = 1;
UPDATE 1
registry=# select * from harbor_user;
user_id | username | email | password | realname | comment | deleted | reset_uuid | salt | sysadmin_flag | creation_time | update_time | password_version
---------+-----------+-------+----------+----------------+----------------+---------+------------+------+---------------+----------------------------+----------------------------+------------------
2 | anonymous | | | anonymous user | anonymous user | t | | | f | 2025-01-15 03:28:49.478067 | 2025-01-15 03:28:50.225759 | sha1
1 | admin | | | system admin | admin user | f | | | t | 2025-01-15 03:28:49.478067 | 2025-04-26 02:47:32.290741 | sha256
(2 rows)
重启Harbor服务生效,然后使用harbor.yaml中配置的初始密码登录。
此时就完成了密码的重置
本文来自博客园,作者:厚礼蝎,转载请注明原文链接:https://www.cnblogs.com/guangdelw/p/18847896