2

I am expecting cryptsetup to prompt me for a passphrase, but instead it's just trying and failing to open a key file:

sudo cryptsetup luksFormat test.img cryptsetup-test

WARNING!
========
This will overwrite data on test.img irrevocably.

Are you sure? (Type uppercase yes): YES
Failed to open key file.
  • The format you are attempting to use is cryptsetup luksFormat <device> [<key file>], therefore cryptsetup-test is being interpreted as a keyfile, which probably isn't what you want and doesn't exist, hence the error Failed to open key file.. A keyfile can be used instead of an interactive password. – Torin Apr 5 '18 at 11:31
  • For those who ended up reading this, but were not being asked for a passphrase after typing "yes" and the command exited quietly, but you expected a passphrase prompt, make sure the YES is upper case. – Konrad Gajewski May 21 '18 at 12:12
2

You are confusing the syntaxes for luksFormat and luksOpen.

luksFormat does not open the device, so doesn't take a device name to map to. So if you try to pass one, it will interpret it as a filename for a key file and try (and probably fail) to open it.

Here's an example of luksFormat:

sudo cryptsetup luksFormat test.img
WARNING!
========
This will overwrite data on test.img irrevocably.

Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:

And an example of luksOpen:

sudo cryptsetup luksOpen test.img cryptsetup-test
Enter passphrase for test.img

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.