{"record":{"id":"660a2589e2784417","repo":"kopia/kopia","slug":"error-getting-password","errorCode":null,"errorMessage":"error getting password","messagePattern":"error getting password","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_user_hash_password.go","lineNumber":38,"sourceCode":"\n\tcmd.Flag(\"user-password\", \"Password\").StringVar(&c.password)\n\n\tcmd.Action(svc.repositoryWriterAction(c.runServerUserHashPassword))\n\n\tc.out.setup(svc)\n}\n\n// The current implementation does not require a connected repository, thus the\n// RepositoryWriter parameter is not used. Future implementations will need a\n// connected repository. To avoid a future incompatible change where the\n// 'hash-password' command stops working without a connected repository,\n// a connected repository is required now.\nfunc (c *commandServerUserHashPassword) runServerUserHashPassword(_ context.Context, _ repo.RepositoryWriter) error {\n\tif c.password == \"\" {\n\t\t// when password hash is empty, ask for password\n\t\tpwd, err := askConfirmPass(c.out.stdout(), \"Enter password to hash: \")\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error getting password\")\n\t\t}\n\n\t\tc.password = pwd\n\t}\n\n\th, err := user.HashPassword(c.password)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"hashing password\")\n\t}\n\n\tc.out.printStdout(\"%s\\n\", h)\n\n\treturn nil\n}\n","sourceCodeStart":20,"sourceCodeEnd":53,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_user_hash_password.go#L20-L53","documentation":"`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.","triggerScenarios":"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).","commonSituations":"Running in CI or a non-interactive context without passing the password; stdin redirected; SSH session without TTY allocation.","solutions":["Pass the password on the command line via the password flag so no prompt occurs","Run in an interactive terminal with a working TTY","In scripts, feed both password lines to stdin or use your shell's secret prompt helper","Check that the terminal is not consuming/closing stdin prematurely"],"exampleFix":"// before\n$ kopia server user hash-password < /dev/null\n// after\n$ kopia server user hash-password --password=\"$SECRET\"","handlingStrategy":"validation","validationCode":"[ -n \"$PASSWORD\" ] && kopia server user hash-password --password=\"$PASSWORD\" || { echo \"password required in non-interactive shells\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the password flag in any non-interactive context","Allocate a TTY when running remotely (ssh -t)","Never leave stdin closed/null when prompting is expected"],"tags":["interactive-input","password","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}