Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

restic "Fatal: wrong password or no key found": which password restic tried and why no key accepted it

Technical article
Backup & Recovery

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When restic prints Fatal: wrong password or no key found, it tried the password it was given against the key files in the repository and none of them accepted it. Either the password is not the one for this repository, or the job is pointed at a different repository from the one you think, or the password reached restic changed. From restic 0.17.1 the exit status is 12, which a monitoring system can match.

Do not guess passwords at the repository. First find out which password source the job really uses, then test that source with a read-only command.

What the error means

A restic repository holds one or more key files in its keys directory. restic's design page says each key file holds what is needed to derive the repository's master keys from a user's password, using the scrypt key derivation function. restic's design page also says "A repository can have several different passwords, with a key file for each", and that when the password is incorrect "the computed MAC will not match".

In the restic 0.17.3 source, internal/repository/key.go defines the message: ErrNoKeyFound = errors.New("wrong password or no key found"). The same file shows the reading: restic lists the key files, tries to decrypt each with the password, treats an authentication failure as a wrong password for that key and moves to the next, and returns this error when none worked. cmd/restic/main.go prints it as Fatal: followed by the text and sets exit status 12.

The message does not tell a wrong password from a location with no usable key; the steps below do.

Two further readings of 0.17.3 explain how the password arrives:

  • cmd/restic/global.go uses the command if only a command is set, the file (--password-file or RESTIC_PASSWORD_FILE) if only a file is set, and consults RESTIC_PASSWORD only when neither is set. A leftover RESTIC_PASSWORD_FILE therefore wins over RESTIC_PASSWORD. A file and a command together stop with "Password file and command are mutually exclusive options".
  • At a terminal with no password supplied restic asks up to three times, printing "Try again" between attempts. When the password comes from a file, a command or a variable, or there is no terminal, it has one attempt. restic checks at most 20 key files per attempt and prints a different message, "maximum number of keys reached", when that limit is hit.

Likely causes

Cause What you see How to confirm
Password changed in the repository, job still has the old one Job worked until a key change, then fails every run restic key list with the new password opens; the job's password does not
Wrong password source wins (stale RESTIC_PASSWORD_FILE, other environment in cron or a service) Works by hand, fails from the scheduler Compare the environment the job really runs with, not your login shell's
Job points at a different repository The password is right for another repository Print the repository location the job uses and compare it with the one you test
Password altered on the way in Typed password works, file or command route fails The password begins or ends with a space (see Fix); restic 0.17.3 removes a byte order mark from a password file, so that is not the cause on that release
Shell or terminal changed the characters Fails only in one shell or terminal Same password works through --password-file

Prove the cause before changing anything

All of these only read. restic's key list takes a read lock and changes nothing.

1. Which restic and which exit status.

restic version

restic's scripting page lists exit status 12 as "Wrong password (since restic 0.17.1)". Our reading: an older release has no dedicated status for it.

2. What the job really uses. Read the script, cron entry or unit file for the lines that set RESTIC_REPOSITORY, RESTIC_PASSWORD_FILE, RESTIC_PASSWORD_COMMAND, RESTIC_PASSWORD, --repo and --password-file. In an interactive shell, print the non-secret settings and only report whether the secret is set. Do not share this output, because an address or command can carry a password:

env | grep -E '^RESTIC_(REPOSITORY|REPOSITORY_FILE|PASSWORD_FILE|PASSWORD_COMMAND|KEY_HINT)='
[ -n "$RESTIC_PASSWORD" ] && echo "RESTIC_PASSWORD is set"

A file and a command together stop restic with the mutually exclusive message. A file (or a command) together with RESTIC_PASSWORD means the file or command is used and the variable is ignored.

3. Look at the repository location without a password. For a repository on a mounted path:

ls /mnt/nas01/restic-repo
ls /mnt/nas01/restic-repo/keys

A real repository has a config file and data and keys directories, and at least one file under keys. A missing keys directory or an empty one means this is not the repository you wanted, or the repository is damaged: restic has nothing to open. The number of files under keys is the number of passwords set up.

4. Test one password source at a time.

restic -r /mnt/nas01/restic-repo key list; echo "exit status $?"
restic -r /mnt/nas01/restic-repo --password-file /etc/restic/password key list; echo "exit status $?"

The first asks you for a password, up to three times at a terminal, so it may print "Try again". A good result is a table of key IDs, users, hosts and creation times, and restic's documentation says "Note that the currently used key is indicated by an asterisk (*)." A bad result is Fatal: wrong password or no key found. If your own typed password opens and the job's file does not, the job's secret is the problem, not the repository.

5. Terminal emulators on Windows. If the failure appears only inside MSYS2, Cygwin, Mintty or rxvt, see the Fix section. restic's preparing-a-repository page says those terminals can produce a password error.

Fix

Fix the password source, not the repository. Our own advice: never run restic init over a location that already holds data.

The job has the wrong password or the wrong repository

The usual change is one line in the job's password file or environment file. Replace restic-nightly.env and password with your names.

First save the current state:

cp -p /etc/restic/restic-nightly.env /etc/restic/restic-nightly.env.2026-12-02
cp -p /etc/restic/password /etc/restic/password.2026-12-02

Risk: the next edit changes which repository and which password the nightly backup job uses. A wrong value stops the backup from running, and a mistake in the repository line points the job at another repository.

Open the file in your editor and correct the repository line, or put the password that key list accepted into the password file. The password file route removes a byte order mark at the start and whitespace around the contents (reading of loadPasswordFromFile in 0.17.3), so a trailing newline is harmless. Keep the file readable by its owner only, as restic's FAQ asks ("0600 and owned by root").

To undo it: copy the saved files back, then run the check in step 4 again.

cp -p /etc/restic/restic-nightly.env.2026-12-02 /etc/restic/restic-nightly.env
cp -p /etc/restic/password.2026-12-02 /etc/restic/password

The saved copies hold the old password in plain text. When the check in step 4 passes, remove them, or keep them only with the same owner-only permissions as the originals (cp -p keeps the mode).

The password cannot be carried by a file

The file and command routes strip whitespace from both ends of what they read. A password that begins or ends with a space therefore reaches restic changed. This is our own conclusion from that reading, not a statement in the documentation. The same password typed at the prompt opens the repository while the file route fails.

The remedy is a second key with a plain password for the job. Only a person who holds a working password can add it.

First save the current state, which includes the job's password file:

restic -r /mnt/nas01/restic-repo key list > key-list-before.txt
cp -p /etc/restic/password /etc/restic/password.before-key-add.2026-12-02

Risk: the next command adds a new key file to the repository. It does not remove any existing key, but the repository then has one more password that must be stored and protected.

Add the key. restic asks for an existing password, then the new one twice:

restic -r /mnt/nas01/restic-repo key add

Risk: the next step replaces the password in the job's password file. If the new key is later removed without putting the saved file back, the next run fails with the same Fatal message.

Then put the new plain password in the job's password file by the steps in the previous section, and run the check in step 4.

To undo it, first put the job's password file back from the copy saved above, which holds the password of a key that still exists:

cp -p /etc/restic/password.before-key-add.2026-12-02 /etc/restic/password

Then remove the new key. List the keys; the new key is the ID that is not in key-list-before.txt:

restic -r /mnt/nas01/restic-repo key list

Disruptive step: the next command deletes the key file with the ID you give, and a wrong ID removes another valid password; restic's documentation gives no way to undo it. restic stops with "refusing to remove key currently used to access repository" if you try to remove the key in use for that command, so when restic asks for the repository password, give an older password, not the new one.

Remove the key, replacing NEWKEYID with the ID found above, then list the keys again:

restic -r /mnt/nas01/restic-repo key remove NEWKEYID
restic -r /mnt/nas01/restic-repo key list

Keep that saved copy owner-only.

A Windows terminal emulator

restic's page says that under MSYS2 or Cygwin the password prompt may fail and that the winpty tool is the workaround. Run the read-only check through it:

winpty restic -r /mnt/nas01/restic-repo key list

No known password

If no known password opens any key, restic's design and encryption pages describe no way around the password, and the key commands (key list, key add, key remove) all open the repository with one first. The effort goes into finding it: the person who ran the original restic init, the old job files and the place the team keeps secrets. Our own advice: record where each repository's password lives before the day it is needed. Custody and loss are covered in Encryption keys for customer-held backups: who holds them and what losing or copying one means.

Example (illustrative): fs01 backs up to /mnt/nas01/restic-repo. On 1 December an administrator ran restic key passwd to rotate the password. The nightly job still reads /etc/restic/password, which holds the old one. On 2 December the job ends with Fatal: wrong password or no key found and status 12. ls /mnt/nas01/restic-repo/keys shows one file, so one password exists. restic -r /mnt/nas01/restic-repo key list with the new password opens and shows one key with an asterisk. The same command with --password-file /etc/restic/password fails. The cause is the old password in the file: key passwd creates a new key and removes the old key ID (the help text of restic 0.17.3). The administrator saves both files, puts the new password in the file and runs the check again.

Confirm the fix

  1. restic -r /mnt/nas01/restic-repo --password-file /etc/restic/password key list shows the key table and exit status 0.
  2. restic -r /mnt/nas01/restic-repo snapshots lists the snapshots you expect.
  3. The next scheduled backup run finishes with exit status 0 (3 means some source data could not be read, per the scripting page).

What to watch afterwards

  • Alert on exit status 12 separately from status 1, so a password fault is not buried among generic failures.
  • After any key add, key passwd or key remove, run key list and update the stored password in the same change.
  • Keep one password record outside the server being backed up, so a lost server does not take its password with it.

Risks and limits

  • These commands have not been run or lab-tested.
  • Status 12 and the 20-key limit are readings of restic 0.17.x; other releases may differ.
  • restic's design and encryption pages name no recovery route for a repository whose passwords are all lost.
  • key remove and key passwd take an exclusive lock on the repository; do not run them while a backup is running.
  • The documentation pages carry no date; the version is read from the 0.17.3 path.

Sources

  • Preparing a new repository — restic project, no date shown, accessed 2 December 2026
  • Scripting — restic project, no date shown, accessed 2 December 2026
  • Encryption — restic project, no date shown, accessed 2 December 2026
  • Terminology — restic project, no date shown, accessed 2 December 2026
  • FAQ — restic project, no date shown, accessed 2 December 2026
  • key.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026
  • main.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026
  • global.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026
  • cmd_key_remove.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026
  • cmd_key_list.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026
  • cmd_key_passwd.go — restic source repository, tag v0.17.3, no date shown, accessed 2 December 2026