This article helps you to retrieve or reset the Harbor admin password in below scenarios:
You forgot the Harbor admin password configured initially during the Harbor tile deployment.
You have updated the admin password from Harbor UI and forgot it.
Log in to Harbor instance by running:
bosh -d harbor-container-registry-xxxxxxxxxxxxxxxxxxxx ssh
Provide root privileges by running sudo -i.
Set the docker environment alias by running the below command:
alias docker='/var/vcap/packages/docker/bin/docker -H unix:///var/vcap/sys/run/docker/dockerd.sock'
Run docker ps and make a note of the harbor-adminserver or harbor-core container id.
Harbor version <=1.7: docker exec to the harbor-adminserver container
Harbor version >=1.8: docker exec to the harbor-core container
For example:
docker exec -it 0874fd181f8b bash
where 0874fd181f8b is the respective CONTAINER ID
Run env and make a note of HARBOR_ADMIN_PASSWORD.
Note: This is the admin password configured during initial harbor tile vm deployment. This entry does not get updated if the password is changed later from Harbor GUI.
If the administrator have changed the harbor admin password from GUI and forgot it later, follow the below steps to reset back to the initial configured one.
Note: The below steps are going to modify the harbor database and need to be performed with caution. If you need help with these steps, please file a Support Request with VMware support.
Run docker ps and confirm that all the containers are running.
Login to the harbor-db container by running the following command:
docker exec -it harbor-db bash
Connect to the database by running the following commands:
psql -U postgres -d registry
Run the below command to list the harbor users:
select * from harbor_user;
Note: Make a note of the admin user_id for the next step
Run the below command to reset the admin password
update harbor_user set salt='', password='' where user_id = 1;
Note: This will set the admin password back to what it was initially configuring during harbor tile vm deployment.
Exit from the db and container by running \q.
Restart Harbor service by running:
monit restart harbor