Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #264441 > unrolled thread

zfs load-key on boot randomly reports wrong password if I type too fast

Started bycen <imbacen@gmail.com>
First post2023-12-08 21:30 +0100
Last post2023-12-08 22:20 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.debian.user


Contents

  zfs load-key on boot randomly reports wrong password if I type too  fast cen <imbacen@gmail.com> - 2023-12-08 21:30 +0100
    Re: zfs load-key on boot randomly reports wrong password if I type  too fast David <bouncingcats@gmail.com> - 2023-12-08 22:00 +0100
      Re: zfs load-key on boot randomly reports wrong password if I type  too fast cen <imbacen@gmail.com> - 2023-12-11 22:00 +0100
    Re: zfs load-key on boot randomly reports wrong password if I type  too fast David Wright <deblis@lionunicorn.co.uk> - 2023-12-08 22:20 +0100

#264441 — zfs load-key on boot randomly reports wrong password if I type too fast

Fromcen <imbacen@gmail.com>
Date2023-12-08 21:30 +0100
Subjectzfs load-key on boot randomly reports wrong password if I type too fast
Message-ID<HIPDX-ceLd-9@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Hi

I have an encrypted ZFS volume which I unlock at boot time using this 
systemd service:

[Unit]
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/zfs load-key -a
StandardInput=tty-force

[Install]
WantedBy=zfs-mount.service


I have a very weird issue that.. if I type too fast the password is 
wrong. I know this sounds weird but it's true..

I can type the same password fast and it is wrong, then I type it very 
slowly the third time and it works.

I feel like it must be some weird thing with the boot terminal input 
rate or key detection but I have no clue where to start looking.

Unfortunately the prompt has no *** char masking so I am not even sure 
if keys are being registered or what is happening below.

I also have encrypted boot drive which unlocks first but that terminal 
looks different and has no issues.

I also tried a few other ways to load but I can't get either to work:

#ExecStart=/usr/bin/bash -c 'systemd-ask-password "ZFS password" 
--no-tty | zfs load-key -a'
#ExecStart=plymouth ask-for-password --prompt="Password for zfs" 
--number-of-tries=5 --command="/usr/sbin/zfs load-key -a"


Any clues welcome

[toc] | [next] | [standalone]


#264443 — Re: zfs load-key on boot randomly reports wrong password if I type too fast

FromDavid <bouncingcats@gmail.com>
Date2023-12-08 22:00 +0100
SubjectRe: zfs load-key on boot randomly reports wrong password if I type too fast
Message-ID<HIQ6Z-ceUK-3@gated-at.bofh.it>
In reply to#264441
On Fri, 8 Dec 2023 at 20:22, cen <imbacen@gmail.com> wrote:

> I have a very weird issue that.. if I type too fast the password is wrong. I know this sounds weird but it's true..
>
> I can type the same password fast and it is wrong, then I type it very slowly the third time and it works.
>
> I feel like it must be some weird thing with the boot terminal input rate or key detection but I have no clue where to start looking.

[...]

> Any clues welcome

Hi,

I have experienced something similar, so it does not sound weird to me.
So my solution to my similar problem, might be a useful clue for you :)

I have a Toshiba Satellite Pro laptop [1] whose default keyboard rate settings
cause manual typing of the cryptsetup password entry in the initrd environment
to fail more often than not. A very annoying situation.

I fix this situation by causing /sbin/kbdrate to run inside the initrd
environment,
before the cryptsetup password entry occurs.

A while ago I wrote an email message about how I do that here:
  https://lists.debian.org/debian-user/2022/01/msg00105.html
  https://lists.debian.org/debian-user/2022/01/msg00106.html

Maybe this method can help you with your encrypted ZFS password entry,
I don't know.

[1] Toshiba Satellite Pro C665 Model No PSC2FA-002002

[toc] | [prev] | [next] | [standalone]


#264655 — Re: zfs load-key on boot randomly reports wrong password if I type too fast

Fromcen <imbacen@gmail.com>
Date2023-12-11 22:00 +0100
SubjectRe: zfs load-key on boot randomly reports wrong password if I type too fast
Message-ID<HJVxD-cUz3-1@gated-at.bofh.it>
In reply to#264443

[Multipart message — attachments visible in raw view] — view raw

That is a good pointer, I will start experimenting with kdbrate and see 
if anything improves.

I did come up with the following contraption which helps at least seeing 
what is going on and so far

it seems that the password is 1 char short on invalid attempt and it is 
usually the last char that seems to be missing.

I will probably figure it out through testing eventually.

#!/bin/bash

MAX_ATTEMPTS=3
attempt=0

while [ "$attempt" -lt "$MAX_ATTEMPTS" ]; do
    printf "ZFS load-key password (attempt $((attempt + 1)) of 
$MAX_ATTEMPTS): "
    PASSWORD=""

    while true; do
        char=$(dd bs=1 count=1 2>/dev/null)

        if [ -z "$char" ] || [ "$char" = "$(printf '\n')" ]; then
            break
        fi

        printf "*"

        PASSWORD="${PASSWORD}${char}"
    done

    echo "$PASSWORD" | /usr/sbin/zfs load-key -a

    if [ $? -eq 0 ]; then
        echo "Password accepted. Exiting."
        exit 0
    else
        echo "Incorrect password. Please try again."
        FIRST="${PASSWORD:0:1}"
        LAST="${PASSWORD: -1}"
        LEN=${#PASSWORD}
        echo "Got $FIRST ... $LAST, length $LEN"
        attempt=$((attempt + 1))
        sleep 3
    fi
done

echo "Maximum attempts reached. Exiting."



On 12/8/23 21:53, David wrote:
> On Fri, 8 Dec 2023 at 20:22, cen<imbacen@gmail.com>  wrote:
>
>> I have a very weird issue that.. if I type too fast the password is wrong. I know this sounds weird but it's true..
>>
>> I can type the same password fast and it is wrong, then I type it very slowly the third time and it works.
>>
>> I feel like it must be some weird thing with the boot terminal input rate or key detection but I have no clue where to start looking.
> [...]
>
>> Any clues welcome
> Hi,
>
> I have experienced something similar, so it does not sound weird to me.
> So my solution to my similar problem, might be a useful clue for you :)
>
> I have a Toshiba Satellite Pro laptop [1] whose default keyboard rate settings
> cause manual typing of the cryptsetup password entry in the initrd environment
> to fail more often than not. A very annoying situation.
>
> I fix this situation by causing /sbin/kbdrate to run inside the initrd
> environment,
> before the cryptsetup password entry occurs.
>
> A while ago I wrote an email message about how I do that here:
>    https://lists.debian.org/debian-user/2022/01/msg00105.html
>    https://lists.debian.org/debian-user/2022/01/msg00106.html
>
> Maybe this method can help you with your encrypted ZFS password entry,
> I don't know.
>
> [1] Toshiba Satellite Pro C665 Model No PSC2FA-002002
>

[toc] | [prev] | [next] | [standalone]


#264445 — Re: zfs load-key on boot randomly reports wrong password if I type too fast

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2023-12-08 22:20 +0100
SubjectRe: zfs load-key on boot randomly reports wrong password if I type too fast
Message-ID<HIQql-cfgM-1@gated-at.bofh.it>
In reply to#264441
On Fri 08 Dec 2023 at 21:22:23 (+0100), cen wrote:
> 
> I have an encrypted ZFS volume which I unlock at boot time using this
> systemd service:
> 
> [Unit]
> DefaultDependencies=no
> After=zfs-import.target
> Before=zfs-mount.service
> 
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> ExecStart=/usr/sbin/zfs load-key -a
> StandardInput=tty-force
> 
> [Install]
> WantedBy=zfs-mount.service
> 
> 
> I have a very weird issue that.. if I type too fast the password is
> wrong. I know this sounds weird but it's true..
> 
> I can type the same password fast and it is wrong, then I type it very
> slowly the third time and it works.
> 
> I feel like it must be some weird thing with the boot terminal input
> rate or key detection but I have no clue where to start looking.

Do pages like these throw any light on the problem?

  https://superuser.com/questions/1579208/delay-after-hitting-escape
  https://unix.stackexchange.com/questions/608142/whats-the-effect-of-escape-time-in-tmux/608179

> Unfortunately the prompt has no *** char masking so I am not even sure
> if keys are being registered or what is happening below.

I would like it if you could turn this feature on.
Odd ones do but most don't.

Cheers,
David.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web