How to reset a forgotten admin password in Nexus 3.x
Did you follow our tutorial about hosting a private npm registry using Sonatype Nexus3?
What if during the configuration, our brave sysadmin lost the admin password (Yes, it happene to me).
This post assumes the infrastructure described in our tutorial: Sonatype Nexs running in a Docker container
Connecting to the db
Nexus 3 uses several OrientDB databases, and the admin password is written there.
SSH in the RancherOS host, and find the PID of the nexus 3
$ nexuspid=$(docker ps --filter "name=nexus" -q)
attach connect to the running containet
docker exec -i -t $nexuspid /bin/bash
docker attach, otherwise stdin and stdout will be the same fo the nexus process –> you can’t type commands!
From the container, start the orientdb console:
$ cd /opt/sonatype/nexus $ java -jar ./lib/support/nexus-orient-console.jar
When the orientdb console is up and running, connect to the db:
> connect plocal:../sonatype-work/nexus3/db/security admin admin
and reset the admin password by executing this command
> update user SET password="$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA==" UPSERT WHERE id="admin"
And close the orient console
Now, stop and restart the conatiner. The admin password has been reverted to the original