Re: cryptsetup - No key available with passphrase

Lars Francke <[email protected]> Thu, 2 Mar 2023 17:23:33 +0100
Newsgroups dev.linux.lists.cryptsetup
Message-ID <CAD-Ua_h2GDZexz=DC3YA88nO-OhXKyGp1v2D6rWvHHQVwtCgFw@mail.gmail.com>
Milan,

thank you for the quick reply. I did try that but unfortunately:

root@archiso ~ # echo 'a' | cryptsetup luksFormat /dev/nvme0n1p5
WARNING: Device /dev/nvme0n1p5 already contains a 'crypto_LUKS'
superblock signature.
root@archiso ~ # echo 'a' | cryptsetup luksOpen /dev/nvme0n1p5 cryptroot
No key available with this passphrase.


I also just used the `echo` method to make it easier to replicate.
The same happens when I just press "a" on my keyboard and hit enter.

What makes it even weirder is that it did work _once_:

# echo 'a' | cryptsetup luksFormat /dev/nvme0n1p5
WARNING: Device /dev/nvme0n1p5 already contains a 'crypto_LUKS'
superblock signature.
# echo 'a' | cryptsetup luksOpen /dev/nvme0n1p5 cryptroot

I'm at a loss but will now read the section in the man page that you
referred to.

Thanks again,
Lars
On Thu, Mar 2, 2023 at 4:01 PM Milan Broz <[email protected]> wrote:
>
> On 3/2/23 15:03, Lars Francke wrote:
> > Hello,
> >
> > I am trying to setup LUKS (and I've done it like this in the past,
> > like...two weeks ago and it just stopped working) and am running into
> > the following issue:
> >
> > root@archiso ~ # echo 'a' | cryptsetup  luksFormat --batch-mode /dev/nvme0n1p5 -
> > root@archiso ~ # echo 'a' | cryptsetup luksOpen /dev/nvme0n1p5 cryptroot -
> > No key available with this passphrase.
>
> This is just a little bit confusing handling of end-of-line if used with "-"
> (see section "Passphrase processing for LUKS" in man cryptsetup).
>
> The first command will create passphrase "a\n" (including \n !) while the second
> command will process only "a" (you can to use --key-file=- there for luksOpen,
> it has different syntax.)
>
> But just do not use "-" here, cryptsetup will do what needed automatically.
> Also batch mode is implicit if it detects pipe input, so just use:
>
> # echo 'a' | cryptsetup luksFormat /dev/nvme0n1p5
> # echo 'a' | cryptsetup luksOpen /dev/nvme0n1p5 cryptroot
>
> and it should work as expected (password will be "a").
>
> Milan