Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatticlly add keyscript to crypttab #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions yubikey-luks-enroll
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,21 @@ else
if [ "$DBG" = "1" ]; then echo "LUKS key: $R"; fi
fi

# add keyscript to /etc/crypttab

if [[ -b ${DISK} ]]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are several yubikeys connected to a machine I would not like to update the initramfs each time a yubikey is added. So we should use a command line parameter here. Like

-u    update initramfs config

then
echo "${DISK} searching from disk/by-uuid"
UUID="$( ls -l /dev/disk/by-uuid/ | grep $( basename ${DISK} ) | awk '{ print $9 }' )"
else
echo "${DISK} searching from crypttab"
eval $( grep ${DISK} /etc/crypttab | awk '{ print $2 }' )
fi

if ! grep 'keyscript=/usr/share/yubikey-luks/ykluks-keyscript' /etc/crypttab
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use square brackets here, to have a consistent code style.

Also: I think we should only match for "keyscript"; so that we do not add a 2nd keyscript if another keyscript was already configured!

then
sed -i "/${UUID}/ s/$/,keyscript=\/usr\/share\/yubikey-luks\/ykluks-keyscript/" /etc/crypttab
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this breaks for me. I think this is not very robust. Even in another shell (bash), this starts to break.

update-initramfs -u
fi

exit 0