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)

Now attach connect to the running containet

docker exec -i -t $nexuspid /bin/bash

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

> exit

Now, stop and restart the conatiner. The admin password has been reverted to the original admin123

                [index]: index.html
                [getting_started]: getting_started.html
                [key_concepts]: key_concepts.html
                [faq]: faq
                    [triggersmodproxy]: triggersmodproxy.html
                    [flavoursawsec2]: flavoursawsec2.html
                    [flavoursawscf]: flavoursawscf.html
                    [flavoursdigitalocean]: flavoursdigitalocean.html
                    [flavoursgooglecloudplatform]: flavoursgooglecloudplatform.html
                    [flavoursazure]: flavoursazure.html
                    [flavoursoracle_compute]: flavoursoracle_compute.html
                    [clicli_home]: clicli_home.html
                    [clicli_quick_reference]: clicli_quick_reference.html
                [blog]: blog