kopia/kopia · error
can't get password
Error message
can't get password
What it means
askPass reads the repository password interactively from a terminal (or from stdin when supported). If every read attempt fails or yields nothing (EOF, no TTY, read error), it gives up and returns the generic error "can't get password".
Solutions
- Pass the password explicitly: --password or the KOPASSWORD environment variable
- Ensure stdin is an open interactive TTY (avoid `kopia ... < /dev/null`)
- Use --use-.saved-credentials or kopia's credentials file for scripted runs
- Check terminal emulation/SSH pty allocation when running remotely
Example fix
// before (script, no TTY) kopia repository connect s3 ... // after KOPASSWORD=secret kopia repository connect s3 ...
Defensive patterns
Strategy: fallback
Validate before calling
// ensure a TTY or explicit password source before invoking
if password == "" && os.Getenv("KOPASSWORD") == "" && !term.IsTerminal(int(os.Stdin.Fd())) {
return errors.New("no interactive terminal and no KOPASSWORD set")
} Try / catch
out, err := askPass(...)
if err != nil {
if strings.Contains(err.Error(), "can't get password") {
// fall back to KOPASSWORD or --password
}
} Prevention
- Set KOPASSWORD in scripts/CI
- Redirect password via --password or config credentials
- Avoid piping empty stdin into kopia prompts
When it happens
Trigger: Running kopia non-interactively without KOPASSWORD/--password and stdin unavailable or closed; terminal read failing after retries in askPass.
Common situations: CI jobs and cron/scripts without a TTY, piped empty stdin, kopia prompts consumed by other tooling, or entering empty input twice.
Related errors
- get password
- getting password
- can't open source repository
- error connecting to repository
- error getting password
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/13439c023896b312.
Report an issue: GitHub.
Appendix: source
Thrown at cli/password.go:120
for range 5 {
fmt.Fprint(out, prompt) //nolint:errcheck
passBytes, err := term.ReadPassword(fd)
if err != nil {
return "", errors.Wrap(err, "password prompt error")
}
fmt.Fprintln(out) //nolint:errcheck
if len(passBytes) == 0 {
continue
}
return string(passBytes), nil
}
return "", errors.New("can't get password")
}
var errFdConversionOverflows = errors.New("uintptr file descriptor conversion to int overflows")
func intFd(f *os.File) (int, error) {
fd := f.Fd()
if fd <= math.MaxInt {
return int(fd), nil
}
return -1, errFdConversionOverflows
}
View on GitHub (pinned to 82495e54b5)