ServerHandbook live check: run log ------------------------------------------------------------------------------ Article https://serverhandbook.com/kb/dspace-reset-admin-password Check scripts/live/checks/dspace-reset-admin-password.mjs (sha256 5eab96c407233c3bcd87d1969143d8daf75c19bb342a4f1ffc4ad3df0bf9bd0a) Ran at 2026-11-20T04:04:32Z (561 s) Result PASS, all 30 claims held Tested on System Ubuntu 26.04.1 LTS Kernel 7.0.0-43-generic Package openjdk-21-jdk-headless 21.0.13.1+2-1~26.04.1 Package maven 3.9.12-1 Package ant 1.10.15-1build1 Package postgresql-17 17.12-1.pgdg26.04+1 Package dspace 10.1 Package solr 9.11.0 Setup A fresh Ubuntu 26.04 server (8 GB of memory) with DSpace 10.1 installed as lesson 1 of the DSpace course installs it (PostgreSQL, Solr 9.11.0, the backend as services; done by the check before the first step shown), reached over SSH as a sudo user. Every version above was read from the server at run time. Passwords used on the throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test ------------------------------------------------------------------------------ What the steps changed on the server (recorded before the first step and after the last) Packages added (0) Packages upgraded (0) Packages removed (0) Services enabled at boot (0) Services disabled (0) Listening sockets opened (0) Listening sockets closed (0) Files added in /etc (0) Files changed in /etc (0) Files removed from /etc (0) Disk used on / (includes logs written during the run): +18.9 MB ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Claims (30), each with what the run saw ------------------------------------------------------------------------------ 1. ok a bare Ubuntu 26.04 server box (web-server) starts 2. ok (setup) the tools: Java 21, Ant, git, Maven, Node 3. ok (setup) the PostgreSQL project's apt repository (26.04 ships 18; DSpace 10 supports up to 17) 4. ok (setup) PostgreSQL 17 5. ok (setup) role and database dspace 6. ok (setup) the dspace user and /dspace 7. ok (setup) Solr 9.11.0 on 127.0.0.1:8983 8. ok (setup) Solr answers 9. ok (setup) the DSpace 10.1 source and local.cfg 10. ok (setup) mvn package 11. ok (setup) ant fresh_install 12. ok (setup) database migrate 13. ok (setup) the Solr cores 14. ok (setup) Solr is back with the cores 15. ok (setup) the backend service 16. ok (setup) the REST API answers: DSpace 10.1 17. ok (setup) the administrator 18. ok (setup) the administrator signs in with the password set at install 19. ok dspace user --list prints every account with its email | eb700177-543d-4e69-9712-6d63999b4437 admin@example.org/null Admin, Ada | d17c6f75-0c7e-48df-9b89-f3c83e58b577 editor@example.org/null Editor, Eve 20. ok a wrong password: the REST login answers 401 | 401 21. ok two different passwords: "Passwords do not match. Password not set" | Enter new password for user 'admin@example.org': | Enter new password again to verify: | Passwords do not match. Password not set | No changes. 22. ok after the mismatch the old password still works (nothing changed) 23. ok the same password twice: the command ends without an error | Enter new password for user 'admin@example.org': | Enter new password again to verify: | Modified EPerson eb700177-543d-4e69-9712-6d63999b4437 24. ok the new password: the REST login answers 200 | 200 25. ok the old password no longer works: 401 | 401 26. ok an email with no account: "No such EPerson" | No such EPerson 27. ok create-administrator with an existing email: "Administrator account created" | Administrator account created 28. ok that account now signs in with the password given to create-administrator | 200 29. ok still one account per email (it was updated, not duplicated) | eb700177-543d-4e69-9712-6d63999b4437 admin@example.org/null Admin, Ada | d17c6f75-0c7e-48df-9b89-f3c83e58b577 editor@example.org/null Editor, Eve 30. ok (tested on) the box reports its OS, kernel and the version of 6 package(s) | PRETTY_NAME="Ubuntu 26.04.1 LTS" | VIRT=none | KERNEL=7.0.0-43-generic | PKG ant 1.10.15-1build1 | PKG maven 3.9.12-1 | PKG openjdk-21-jdk-headless 21.0.13.1+2-1~26.04.1 | PKG postgresql-17 17.12-1.pgdg26.04+1 | dspace: DSpace version: 10.1 | solr: /opt/solr-9.11.0 ------------------------------------------------------------------------------ Commands and what they printed (9) ------------------------------------------------------------------------------ $ sudo -iu dspace /dspace/bin/dspace user --list eb700177-543d-4e69-9712-6d63999b4437 admin@example.org/null Admin, Ada d17c6f75-0c7e-48df-9b89-f3c83e58b577 editor@example.org/null Editor, Eve $ rm -f /tmp/ds.cookies $ TOKEN=$(curl -s -c /tmp/ds.cookies -D - -o /dev/null http://localhost:8080/server/api/security/csrf | grep -i '^dspace-xsrf-token:' | cut -d' ' -f2 | tr -d '\r') $ curl -s -o /dev/null -w '%{http_code}\n' -b /tmp/ds.cookies -H "X-XSRF-TOKEN: $TOKEN" --data-urlencode 'user=admin@example.org' --data-urlencode 'password=[password]' http://localhost:8080/server/api/authn/login 401 $ sudo -iu dspace /dspace/bin/dspace user --modify --email admin@example.org --newPassword Enter new password for user 'admin@example.org': Enter new password again to verify: Passwords do not match. Password not set No changes. $ sudo -iu dspace /dspace/bin/dspace user --modify --email admin@example.org --newPassword Enter new password for user 'admin@example.org': Enter new password again to verify: Modified EPerson eb700177-543d-4e69-9712-6d63999b4437 $ rm -f /tmp/ds.cookies $ TOKEN=$(curl -s -c /tmp/ds.cookies -D - -o /dev/null http://localhost:8080/server/api/security/csrf | grep -i '^dspace-xsrf-token:' | cut -d' ' -f2 | tr -d '\r') $ curl -s -o /dev/null -w '%{http_code}\n' -b /tmp/ds.cookies -H "X-XSRF-TOKEN: $TOKEN" --data-urlencode 'user=admin@example.org' --data-urlencode 'password=[new-password]' http://localhost:8080/server/api/authn/login 200 $ rm -f /tmp/ds.cookies $ TOKEN=$(curl -s -c /tmp/ds.cookies -D - -o /dev/null http://localhost:8080/server/api/security/csrf | grep -i '^dspace-xsrf-token:' | cut -d' ' -f2 | tr -d '\r') $ curl -s -o /dev/null -w '%{http_code}\n' -b /tmp/ds.cookies -H "X-XSRF-TOKEN: $TOKEN" --data-urlencode 'user=admin@example.org' --data-urlencode 'password=[old-password]' http://localhost:8080/server/api/authn/login 401 $ sudo -iu dspace /dspace/bin/dspace user --modify --email nobody@example.org --newPassword No such EPerson $ sudo -iu dspace /dspace/bin/dspace create-administrator -e editor@example.org -f Eve -l Editor -c en -p '[new-password]' Administrator account created $ sudo -iu dspace /dspace/bin/dspace user --list eb700177-543d-4e69-9712-6d63999b4437 admin@example.org/null Admin, Ada d17c6f75-0c7e-48df-9b89-f3c83e58b577 editor@example.org/null Editor, Eve ------------------------------------------------------------------------------ The check's source (scripts/live/checks/dspace-reset-admin-password.mjs) As it ran. ------------------------------------------------------------------------------ /** * KB: reset a forgotten DSpace admin password (DSpace course, "Fix it"; plan04 hub-dspace.md error 11). Rented server * (LIVE_VPS + LIVE_VPS_NODOMAIN=1, 8 GB), per release (--releases=26.04,24.04), fresh image each time. * * Hidden setup: DSpace 10.1 backend as lesson 1 installs it (scripts/live/dspace-base.mjs, no web interface: this task * never needs it), with an administrator whose password the "reader" has forgotten. * * What it proves, in the article's order: `dspace user --list` shows the accounts (find the admin's email); a sign-in * with the old guess fails (401) through the REST API; `dspace user --modify --email … --newPassword` prompts twice and * sets it; two passwords that differ print "Passwords do not match. Password not set" and change nothing; the new one * signs in (200); the second way, `create-administrator -e … -p …`, resets an EXISTING account and makes a plain user an * administrator (the source says it looks the email up first). */ import { bareBox, reportBox } from '../lib.mjs' import { AS_DSPACE, basePackages, baseSetup, installDSpace, signInCmd } from '../dspace-base.mjs' export const meta = { box: 'vps' } const RELEASE = process.env.LIVE_BOX_RELEASE || '24.04' // Throwaway test values, scrubbed from every saved file (ctx.secret); the page shows the placeholders. const DB_PASS = '[password]' const OLD_PASS = '[password]' const NEW_PASS = '[password]' const OTHER_PASS = '[password]' const EMAIL = 'admin@example.org' const EDITOR = 'editor@example.org' const DS = `${AS_DSPACE} /dspace/bin/dspace` const check = (ctx) => bareBox(ctx, async ({ sudoUser }) => { for (const s of [DB_PASS, OLD_PASS, NEW_PASS, OTHER_PASS]) ctx.secret(s) const sh = sudoUser() const { run, ask, L } = sh installDSpace(ctx, sh, { release: RELEASE, dbPass: DB_PASS, adminEmail: EMAIL, adminPass: OLD_PASS, ui: false }) // a second, ordinary account (for the create-administrator part) L(`${DS} user --add --email ${EDITOR} --givenname Eve --surname Editor --password '${OTHER_PASS}'`) const status = (pw) => L(signInCmd(EMAIL, pw)).trim().split('\n').pop() ctx.check('(setup) the administrator signs in with the password set at install', status(OLD_PASS) === '200', '') // ── step 1: find the account ──────────────────────────────────────────────────────────── const list = run(`${DS} user --list`, { id: 'user-list' }) ctx.check('dspace user --list prints every account with its email', list.exit === 0 && list.out.includes(EMAIL) && list.out.includes(EDITOR), list.out) // ── step 2: the sign-in that fails (the check readers can run without the web interface) ─ const bad = run(signInCmd(EMAIL, 'a-wrong-guess'), { id: 'login-wrong', show: signInCmd(EMAIL, '[password]') }) ctx.check('a wrong password: the REST login answers 401', /^401$/m.test(bad.out), bad.out) // ── step 3: set a new password (prompts; nothing in the shell history) ────────────────── const mismatch = ask( `${DS} user --modify --email ${EMAIL} --newPassword`, [ [`Enter new password for user '${EMAIL}':`, NEW_PASS], ['Enter new password again to verify:', OTHER_PASS], ], { id: 'err-mismatch' }, ) ctx.check('two different passwords: "Passwords do not match. Password not set"', /Passwords do not match\.\s+Password not set/.test(mismatch.out), mismatch.out) ctx.check('after the mismatch the old password still works (nothing changed)', status(OLD_PASS) === '200', '') const reset = ask( `${DS} user --modify --email ${EMAIL} --newPassword`, [ [`Enter new password for user '${EMAIL}':`, NEW_PASS], ['Enter new password again to verify:', NEW_PASS], ], { id: 'reset' }, ) ctx.check('the same password twice: the command ends without an error', reset.exit === 0 && !/do not match|may not be empty|No such EPerson/.test(reset.out), reset.out) // ── step 4: check it worked ───────────────────────────────────────────────────────────── const good = run(signInCmd(EMAIL, NEW_PASS), { id: 'login-new', show: signInCmd(EMAIL, '[new-password]') }) ctx.check('the new password: the REST login answers 200', /^200$/m.test(good.out), good.out) const old = run(signInCmd(EMAIL, OLD_PASS), { id: 'login-old', show: signInCmd(EMAIL, '[old-password]') }) ctx.check('the old password no longer works: 401', /^401$/m.test(old.out), old.out) // ── a wrong email ─────────────────────────────────────────────────────────────────────── const nobody = run(`${DS} user --modify --email nobody@example.org --newPassword < /dev/null`, { id: 'err-no-such', // the reader types it without the redirect: DSpace stops at the lookup, before any prompt (the output is the same) show: `${DS} user --modify --email nobody@example.org --newPassword`, }) ctx.check('an email with no account: "No such EPerson"', /No such EPerson/.test(nobody.out), nobody.out) // ── the second way: create-administrator on an EXISTING email ─────────────────────────── const CA = (pw) => `${DS} create-administrator -e ${EDITOR} -f Eve -l Editor -c en -p '${pw}'` const ca = run(CA(NEW_PASS), { id: 'create-admin-existing', show: CA('[new-password]') }) ctx.check('create-administrator with an existing email: "Administrator account created"', /Administrator account created/.test(ca.out), ca.out) const caLogin = L(signInCmd(EDITOR, NEW_PASS)).trim().split('\n').pop() ctx.check('that account now signs in with the password given to create-administrator', caLogin === '200', caLogin) const again = run(`${DS} user --list`, { id: 'user-list-after' }) ctx.check('still one account per email (it was updated, not duplicated)', again.out.split('\n').filter((l) => l.includes(EDITOR)).length === 1, again.out) // the shell history the -p way leaves behind (why the page prefers --newPassword) ctx.stepsDone() reportBox(ctx, L, baseSetup(RELEASE, { ui: false }), basePackages(RELEASE).packages, basePackages(RELEASE).extra) }) export default check