LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2021, 02:07 PM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Rep: Reputation: 56
How to auto mount luks partition with keyfile?


Hello

My distro is Fedora 34 with btrfs subvolumes. How to boot luks volume without asking for the password?

This is the partition list created in Fedora's Anaconda installer automatic configuration.

Code:
# lsblk -f
NAME                                          FSTYPE      FSVER LABEL                 UUID                                 FSAVAIL FSUSE% MOUNTPOINT
sda                                                                                                                                       
├─sda1                                        vfat        FAT32                       167C-D77D                             582.7M     3% /boot/efi
├─sda2                                        ext4        1.0                         549c24b5-5c17-4d30-a247-e210ccb8b0af  768.5M    14% /boot
└─sda3                                        crypto_LUKS 2                           13b91ea9-5c16-48b4-8404-91e2160d9b07                
  └─luks-13b91ea9-5c16-48b4-8404-91e2160d9b07 btrfs             fedora_localhost-live 54039dd4-8bc4-46ad-947e-279fe8e3744d   34.8G     9% /home
sr0                                                                                                                                       
zram0                                                                                                                                     [SWAP]

# cat /etc/fstab
UUID=54039dd4-8bc4-46ad-947e-279fe8e3744d /                       btrfs   subvol=root,compress=zstd:1,x-systemd.device-timeout=0 0 0
UUID=549c24b5-5c17-4d30-a247-e210ccb8b0af /boot                   ext4    defaults        1 2
UUID=167C-D77D          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=54039dd4-8bc4-46ad-947e-279fe8e3744d /home                   btrfs   subvol=home,compress=zstd:1,x-systemd.device-timeout=0 0 0

# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-13b91ea9-5c16-48b4-8404-91e2160d9b07 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
These are the steps I did.

Code:
# dd if=/dev/urandom of=/root/sda3.key bs=512 count=4

# chmod 400 /root/sda3.key

# cryptsetup luksAddKey UUID=13b91ea9-5c16-48b4-8404-91e2160d9b07 /root/sda3.key

# cat /etc/crypttab 
luks-13b91ea9-5c16-48b4-8404-91e2160d9b07 UUID=13b91ea9-5c16-48b4-8404-91e2160d9b07 /root/sda3.key luks
But it is not working. I'm still getting luks password screen.

How do I automount luks partition without asking password using keyfile?

Thanks

Last edited by ddenial; 07-27-2021 at 02:08 PM.
 
Old 07-27-2021, 02:24 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Since /dev/sda3 (/) is the encrypted partition, the keyfile should probably be on /dev/sda2 (/boot) instead. That way it can be read and used to unlock the encrypted partition.

Even better would be to have it on a usb so it does not just set there and allow anybody access to that file.
 
1 members found this post helpful.
Old 07-27-2021, 02:56 PM   #3
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by computersavvy View Post
Since /dev/sda3 (/) is the encrypted partition, the keyfile should probably be on /dev/sda2 (/boot) instead. That way it can be read and used to unlock the encrypted partition.

Even better would be to have it on a usb so it does not just set there and allow anybody access to that file.
Nope. Not working. Still the same problem.
 
Old 07-27-2021, 03:02 PM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by ddenial View Post
Nope. Not working. Still the same problem.
And it won't by using the path at that point since /boot is not actually mounted until after the OS is running with / properly mounted. That location does get it visible before the encrypted volume is available, but still has to be accessed by something other than the file system path.

I don't use luks and cannot help a lot, but I am certain the keyfile cannot be inside the encrypted volume and used to unlock it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Uefi and full disk encryption with lvm on luks with luks keyfile lancsuk Slackware 2 04-02-2021 02:43 PM
Keyscript for ubuntu to unlock a luks partition with a keyfile and fallback to a passphrase LBuhler Ubuntu 0 04-22-2020 03:44 PM
How to keep LUKS partition decrypted without USB thumb drive with keyfile present? SirSkorpan Linux - Security 2 11-29-2018 02:31 PM
LXer: How to set up an auto-mounted keyfile based luks partition for your home direct LXer Syndicated Linux News 0 02-13-2009 06:50 AM
LXer: Automatically Unlock LUKS Encrypted Drives With A Keyfile LXer Syndicated Linux News 0 07-09-2008 03:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration