kopia/kopia · error

error getting password

Error message

error getting password

What it means

`kopia server user hash-password` wraps failures from `askConfirmPass` as "error getting password". This means the interactive password acquisition (prompt + verification entry) failed before hashing could occur.

Solutions

  1. Pass the password on the command line via the password flag so no prompt occurs
  2. Run in an interactive terminal with a working TTY
  3. In scripts, feed both password lines to stdin or use your shell's secret prompt helper
  4. Check that the terminal is not consuming/closing stdin prematurely

Example fix

// before
$ kopia server user hash-password < /dev/null
// after
$ kopia server user hash-password --password="$SECRET"
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$PASSWORD" ] && kopia server user hash-password --password="$PASSWORD" || { echo "password required in non-interactive shells" >&2; exit 1; }

Prevention

When it happens

Trigger: Running `kopia server user hash-password` without the password flag, so it prompts via `askConfirmPass`, and the prompt/verification read fails (no TTY, EOF, closed stdin).

Common situations: Running in CI or a non-interactive context without passing the password; stdin redirected; SSH session without TTY allocation.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/660a2589e2784417. Report an issue: GitHub.

Appendix: source

Thrown at cli/command_user_hash_password.go:38

	cmd.Flag("user-password", "Password").StringVar(&c.password)

	cmd.Action(svc.repositoryWriterAction(c.runServerUserHashPassword))

	c.out.setup(svc)
}

// The current implementation does not require a connected repository, thus the
// RepositoryWriter parameter is not used. Future implementations will need a
// connected repository. To avoid a future incompatible change where the
// 'hash-password' command stops working without a connected repository,
// a connected repository is required now.
func (c *commandServerUserHashPassword) runServerUserHashPassword(_ context.Context, _ repo.RepositoryWriter) error {
	if c.password == "" {
		// when password hash is empty, ask for password
		pwd, err := askConfirmPass(c.out.stdout(), "Enter password to hash: ")
		if err != nil {
			return errors.Wrap(err, "error getting password")
		}

		c.password = pwd
	}

	h, err := user.HashPassword(c.password)
	if err != nil {
		return errors.Wrap(err, "hashing password")
	}

	c.out.printStdout("%s\n", h)

	return nil
}

View on GitHub (pinned to 82495e54b5)