5

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.
2
  • 2
    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, 2018 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. May 21, 2018 at 12:12

1 Answer 1

3

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 what it should look like when you use each command:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .