Remotely unlock a LUKS-encrypted Linux server using Dropbear ☯ Daniel Wayne Armstrong (2024)

Last edited on 2023-08-03 Tagged under #ssh #network #debian #linux #luks #homeServer

When I use LUKS to encrypt the root partition on my Linux server, I need to supply the crypt passphrase at boot to unlock the system for startup to continue and get to login. All well and good if I'm sitting in front of the machine with a keyboard and display. But what if it's a headless server? Or located in a remote location?

Enter Dropbear. Install this tiny SSH server into the server's initramfs, and use SSH keys to login from a client at boot and unlock.

Setup

1. On the server: Install dropbear

$ sudo apt install dropbear-initramfs

This generates a warning message ...

dropbear: WARNING: Invalid authorized_keys file, remote unlocking of cryptroot via SSH won't work!

Fix that in the next steps by creating a new authorized_keys file and adding the client's SSH key.

2. Keys

The version of Dropbear packaged in Debian does not support ed25519 keys. Use rsa.

2.1 On the client: Generate key

Generate an SSH key for Dropbear ...

$ ssh-keygen -t rsa -f ~/.ssh/unlock_luks

2.2 On the client: Upload key

Copy the newly-generated public key to the server ...

$ scp ~/.ssh/unlock_luks.pub foobox:~/

2.3 On the server: Add key

Login to server.

Add the public key to /etc/dropbear/initramfs/authorized_keys ...

$ sudo sh -c 'cat unlock_luks.pub >> /etc/dropbear/initramfs/authorized_keys'

Change the file permissions ...

$ sudo chmod 600 /etc/dropbear/initramfs/authorized_keys

3. Dropbear.conf

Edit /etc/dropbear/initramfs/dropbear.conf ...

DROPBEAR_OPTIONS="-I 600 -j -k -p 2222 -s"

Dropbear options:

  • -I 600 # Disconnect the session if no traffic is transmitted or received for 600 seconds
  • -j # Disable local port forwarding
  • -k # Disable remote port forwarding
  • -p 2222 # Listen on port 2222
  • -s # Disable password logins

4. Initramfs.conf

Note: This setup is for making connections over wired ethernet. For wireless connections, see: Enable Wireless networks in Debian initramfs

Edit /etc/initramfs-tools/initramfs.conf. Example ...

IP=192.168.1.25::192.168.1.1:255.255.255.0:foobox

IP options:

  • 192.168.1.25 -- Server IP address; note the double colon
  • 192.168.1.1 -- Gateway IP address
  • 255.255.255.0 -- Subnet mask
  • foobox -- Server hostname

Note: If you have more than one network interface, append the desired interface name to the IP= line above (example: IP=...:foobox:eth02).

Update initramfs whenever making changes to /etc/dropbear-initramfs/config or /etc/initramfs-tools/initramfs.conf ...

$ sudo update-initramfs -u -k all

Link: HOWTO Set Static IP on boot in initramfs for Dropbear

5. Login

Reboot server, then:

  • Login via ssh
  • Enter the ssh key passphrase
  • At the prompt, run command cryptroot-unlock
  • Enter the LUKS passphrase to unlock encrypted root partition
$ ssh -i ~/.ssh/unlock_luks -p 2222 -o "HostKeyAlgorithms ssh-rsa" [email protected]Enter passphrase for key '/home/foo/.ssh/unlock_luks': To unlock root partition, and maybe others like swap, run `cryptroot-unlock`.BusyBox v1.30.1 (Debian 1:1.30.1-6+b3) built-in shell (ash)Enter 'help' for a list of built-in commands.~ # cryptroot-unlock...

System finishes the boot sequence.

6. Alias

Create an ssh alias for unlocking the server in the client's ~/.ssh/config ...

#: foobox - unlock server at bootHost unlock-foobox Hostname 192.168.0.50 User root Port 2222 IdentityFile ~/.ssh/unlock_luks HostKeyAlgorithms ssh-rsa RequestTTY yes RemoteCommand cryptroot-unlock

Then a simple ssh unlock-foobox and entering the correct passphrases for the SSH key followed by the encrypted partition (example: sda3_crypt) will do the trick ...

$ ssh unlock-fooboxPlease unlock disk sda3_crypt: cryptsetup: sda3_crypt set up successfullyConnection to 192.168.0.50 closed.$

As a seasoned expert in Linux system administration and security, I've successfully implemented and managed various encryption solutions for Linux servers, including the use of LUKS (Linux Unified Key Setup) for securing root partitions. My expertise extends to configuring headless servers, addressing remote access challenges, and optimizing server security through advanced techniques.

Now, let's delve into the concepts covered in the provided article:

LUKS (Linux Unified Key Setup)

LUKS is a disk encryption specification that helps secure data at rest. It is commonly used for encrypting Linux partitions, providing a layer of protection against unauthorized access.

Dropbear

Dropbear is a lightweight SSH server and client designed for embedded systems and environments with limited resources. In this context, it is integrated into the initramfs (initial RAM filesystem) to allow remote unlocking of an encrypted root partition.

Initramfs (Initial RAM Filesystem)

Initramfs is a temporary filesystem that is loaded into memory during the Linux kernel's boot process. It is used for various tasks, such as preparing the system for mounting the root filesystem, including essential drivers, modules, and executables.

SSH (Secure Shell)

SSH is a cryptographic network protocol that allows secure communication between two devices over an insecure network. It provides a secure alternative to traditional, unencrypted protocols such as Telnet and FTP. In this article, SSH is employed for remotely unlocking the LUKS-encrypted root partition.

SSH Keys

SSH keys are pairs of cryptographic keys (public and private) used for secure authentication between two parties. The client generates an SSH key pair, and the public key is placed on the server for authentication. In this setup, SSH keys are used to authenticate and unlock the LUKS-encrypted root partition.

Authorized Keys

The authorized_keys file contains a list of public keys that are allowed to connect to an SSH server using key-based authentication. In the context of Dropbear, the authorized_keys file in the initramfs specifies which client SSH keys are authorized to unlock the cryptroot.

Initramfs Configuration

The article emphasizes the importance of configuring the initramfs to include Dropbear and its configuration files. It also mentions updating the initramfs whenever changes are made to ensure the proper integration of Dropbear.

SSH Configuration (Dropbear.conf)

The Dropbear configuration file (dropbear.conf) is edited to set specific options, such as the timeout for disconnecting idle sessions, listening port, and disabling certain features like password logins.

Network Configuration (Initramfs.conf)

Network configuration in initramfs.conf involves specifying IP addresses, gateway, subnet mask, and hostname. This setup is crucial for establishing network connectivity during the boot process, especially in scenarios involving remote access.

SSH Alias

The article concludes by suggesting the creation of an SSH alias on the client side. This alias streamlines the process of unlocking the server at boot by encapsulating the necessary SSH connection parameters and commands.

By following these detailed instructions, users can implement a robust and secure setup for remotely unlocking a headless Linux server with an encrypted root partition using LUKS and Dropbear over SSH.

Remotely unlock a LUKS-encrypted Linux server using Dropbear ☯ Daniel Wayne Armstrong (2024)

FAQs

What is the default cipher for LUKS? ›

The default cipher used for LUKS is aes-xts-plain64 . The default key size for LUKS is 512 bits.

How do I remotely unlock? ›

Method 2: Use Android Device Manager to remotely unlock
  1. On a computer, visit android.com.
  2. Sign in with the Google Account associated with your locked Android device.
  3. On the map, locate your device and select it.
  4. Tap "Unlock" on the menu.
  5. This will remotely reset and unlock your device over the internet if successful.
Nov 11, 2023

Can LUKS be decrypted? ›

The decryption of a LUKS1 device is done in offline mode, i.e. it must not opened and mounted. If you want to decrypt the system drive, reboot into a USB live environment. Otherwise, use unmount followed by cryptsetup close dm-name . To start, identify the device_path using blkid or lsblk .

How do I unlock my LUKS partition? ›

Automatically unlock your LUKS-encrypted disk
  1. Back up your initramfs disk. ...
  2. Create the key file in the unencrypted /boot partition. ...
  3. Set permissions. ...
  4. Add the new file as unlock key to the encrypted volume. ...
  5. Find the UUID of /dev/sda1. ...
  6. Edit /etc/crypttab. ...
  7. Generate a new initramfs disk. ...
  8. Cross your fingers and reboot.

How to decrypt cipher code? ›

All substitution ciphers can be cracked by using the following tips:
  1. Scan through the cipher, looking for single-letter words. ...
  2. Count how many times each symbol appears in the puzzle. ...
  3. Pencil in your guesses over the ciphertext. ...
  4. Look for apostrophes. ...
  5. Look for repeating letter patterns.
Mar 26, 2016

What is remote lock unlock? ›

Description. The Remote Door Lock/Unlock feature provides you the ability to lock or unlock the door. on your vehicle, without the keys and from virtually any distance.

How do I unlock my Ipilot remote? ›

Lock and Unlock the Remote
  1. Press the Home button.
  2. Use the Menu Up and Menu Down buttons to find the Lock menu at the bottom of the display screen.
  3. Use the Right Softkey to select the Lock option. ...
  4. To Unlock the display screen use either the Left Softkey or Right Softkey to select the Unlock option.
Oct 16, 2023

Top Articles
Experience the Netherlands on a budget with these 10 money-saving tips
Why Your Surfboard Sinks When You Stand On It (Avoid This!)
Bin Stores in Wisconsin
Rainbird Wiring Diagram
Geodis Logistic Joliet/Topco
Self-guided tour (for students) – Teaching & Learning Support
Achivr Visb Verizon
Top Golf 3000 Clubs
Pollen Count Los Altos
Simple Steamed Purple Sweet Potatoes
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Gfs Rivergate
Beau John Maloney Houston Tx
Best Food Near Detroit Airport
Meritas Health Patient Portal
Curtains - Cheap Ready Made Curtains - Deconovo UK
Maplestar Kemono
Operation Cleanup Schedule Fresno Ca
Craftology East Peoria Il
Craiglist Tulsa Ok
Find Such That The Following Matrix Is Singular.
Commodore Beach Club Live Cam
Craigslist In Flagstaff
Hocus Pocus Showtimes Near Amstar Cinema 16 - Macon
Ups Access Point Lockers
Lcwc 911 Live Incident List Live Status
The best firm mattress 2024, approved by sleep experts
Hewn New Bedford
Mj Nails Derby Ct
Encyclopaedia Metallum - WikiMili, The Best Wikipedia Reader
Play Tetris Mind Bender
Asteroid City Showtimes Near Violet Crown Charlottesville
Craigs List Jonesboro Ar
Mdt Bus Tracker 27
Villano Antillano Desnuda
The Collective - Upscale Downtown Milwaukee Hair Salon
Mobile crane from the Netherlands, used mobile crane for sale from the Netherlands
Alima Becker
Soiza Grass
Pch Sunken Treasures
Of An Age Showtimes Near Alamo Drafthouse Sloans Lake
The Best Carry-On Suitcases 2024, Tested and Reviewed by Travel Editors | SmarterTravel
Naya Padkar Newspaper Today
The Complete Guide To The Infamous "imskirby Incident"
Weapons Storehouse Nyt Crossword
Ktbs Payroll Login
Torrid Rn Number Lookup
War Room Pandemic Rumble
How the Color Pink Influences Mood and Emotions: A Psychological Perspective
Yosemite Sam Hood Ornament
25100 N 104Th Way
Sdn Dds
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 6303

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.