mirror of
https://github.com/suiryc/archlinux-initrd-ssh-cryptsetup.git
synced 2025-12-16 01:28:57 +03:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3e9382f08 | ||
|
|
8ebd239c7a | ||
|
|
bc04382857 | ||
|
|
e47043f3a1 | ||
|
|
4c1a7741d6 | ||
|
|
6167cbc9cd | ||
|
|
a13fecf645 |
18
ChangeLog
18
ChangeLog
@@ -1,3 +1,21 @@
|
||||
2021-08-15 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.8-1
|
||||
Include 'libgcc_s.so.1' which is necessary for (at least) proper LUKS v2 handling
|
||||
|
||||
|
||||
2020-07-14 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.7-1
|
||||
Dropped 'dsa' private key support; added 'ed25519' private key support
|
||||
|
||||
|
||||
2018-03-13 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.6-1
|
||||
Dropped '-m' option when calling dropbear (latest ArchLinux version does not handle it)
|
||||
|
||||
|
||||
2017-06-25 Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
|
||||
* v0.5-1
|
||||
|
||||
4
PKGBUILD
4
PKGBUILD
@@ -1,6 +1,6 @@
|
||||
# Maintainer: Julien Coloos <julien.coloos [at] gmail [dot] com>
|
||||
pkgname=initrd-ssh-cryptsetup
|
||||
pkgver=0.5
|
||||
pkgver=0.8
|
||||
pkgrel=1
|
||||
pkgdesc="Allows for LUKS-encrypted devices to be unlocked remotely over SSH"
|
||||
arch=('any')
|
||||
@@ -10,7 +10,7 @@ depends=('dropbear' 'cryptsetup' 'mkinitcpio-nfs-utils' 'iproute2')
|
||||
install=$pkgname.install
|
||||
changelog='ChangeLog'
|
||||
source=("http://julien.coloos.free.fr/archlinux/$pkgname-$pkgver.tar.xz" "$pkgname.install")
|
||||
md5sums=('d87a35adbef55db89f32a89f4966a27a'
|
||||
md5sums=('ac5a53fbc288ccce61874488bcbbf58a'
|
||||
'ac60109d80e7bb2af0d66e69aaf178a6')
|
||||
|
||||
package() {
|
||||
|
||||
34
README.md
34
README.md
@@ -1,16 +1,37 @@
|
||||
Personal ArchLinux package combining dropbear and cryptsetup in initrd for unlocking LUKS-encrypted devices either locally (boot console) or remotely over SSH.
|
||||
The code was reworked from [dropbear_initrd_encrypt](https://aur.archlinux.org/packages/dropbear_initrd_encrypt/).
|
||||
The code was reworked from legacy dropbear_initrd_encrypt AUR package.
|
||||
|
||||
|
||||
## Installation
|
||||
After cloning the repo, installation is done as for an AUR package.
|
||||
After cloning the repo, installation is done as for an AUR package, e.g.:
|
||||
|
||||
makepkg -sri
|
||||
|
||||
|
||||
## Dropbear
|
||||
SSH server key need to be generated for `dropbear`.
|
||||
Either a new key can be generated with `dropbearkey`, e.g.:
|
||||
|
||||
dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key
|
||||
Or an existing OpenSSH key can be converted with `dropbearconvert` (useful so that the server fingerprint is the same with both), e.g.:
|
||||
|
||||
dropbearconvert openssh dropbear /etc/ssh/ssh_host_ecdsa_key /etc/dropbear/dropbear_ecdsa_host_key
|
||||
Notes:
|
||||
* `rsa` and `ed25519` types are also handled
|
||||
* OpenSSH keys must be in `PEM` format for `dropbearconvert` to properly work
|
||||
|
||||
If necessary an existing key file can be converted to `PEM` format using `ssh-keygen`:
|
||||
|
||||
ssh-keygen -A -p -m PEM -f /etc/ssh/ssh_host_ecdsa_key
|
||||
|
||||
|
||||
## Configuration
|
||||
As explained upon installation, the following things need to be done:
|
||||
* add the SSH public key to `/etc/dropbear/initrd.authorized_keys`
|
||||
* add the authorized SSH public key to `/etc/dropbear/initrd.authorized_keys`
|
||||
* add the `ip=` kernel command parameter to the bootloader configuration (see https://wiki.archlinux.org/index.php/Mkinitcpio#Using_net)
|
||||
- e.g. with `grub`: add `ip=:::::eth0:dhcp` to `GRUB_CMDLINE_LINUX_DEFAULT` in `/etc/default/grub`, and re-generate the configuration with `grub-mkconfig -o /boot/grub/grub.cfg`
|
||||
* in the `HOOKS` section of `/etc/mkinitcpio.conf`, add `ssh-cryptsetup` before `filesystems`; then rebuild the initramfs: `mkinitcpio -p linux`
|
||||
- when using a non-standard keyboard layout, it is also useful to add the `keymap` hook before `ssh-cryptsetup`, and also move `keyboard` before `keymap`
|
||||
|
||||
The LUKS-encrypted devices to unlock are derived from `/etc/crypttab`.
|
||||
|
||||
@@ -37,9 +58,10 @@ For example:
|
||||
## Building notes
|
||||
1. Modify the sources (features in `src`, and/or package building files)
|
||||
2. If `src` was modified
|
||||
* archive the `src` folder in `$pkgname-$pkgver.tar.xz` file; e.g.: `tar -cJf initrd-ssh-cryptsetup-0.4.tar.xz src`
|
||||
* archive the `src` folder in `$pkgname-$pkgver.tar.xz` file; e.g.: `tar -cJf initrd-ssh-cryptsetup-0.7.tar.xz src`
|
||||
* upload the archive on the online repository (pointed by `PKGBUILD`)
|
||||
3. Update `PKGBUILD`
|
||||
3. Update ChangeLog
|
||||
4. Update `PKGBUILD`
|
||||
* bump `pkgver` if `src` was modified, or `pkgrel` if building files were modified
|
||||
* refresh `md5sums` if necessary (based on `md5sum initrd-ssh-cryptsetup-*.tar.xz initrd-ssh-cryptsetup.install` output)
|
||||
4. Delete generated archive file if any
|
||||
5. Delete generated archive file if any
|
||||
|
||||
@@ -163,7 +163,7 @@ EOF
|
||||
touch "/var/log/lastlog"
|
||||
|
||||
msg "Starting dropbear ..."
|
||||
dropbear -Emsgjk -P "${path_dropbear_pid}" ${sshcs_opt_listen}
|
||||
dropbear -Esgjk -P "${path_dropbear_pid}" ${sshcs_opt_listen}
|
||||
|
||||
# Actual unlocking
|
||||
sshcs_unlock
|
||||
|
||||
@@ -32,7 +32,7 @@ build() {
|
||||
local etc_crypttab="/etc/crypttab"
|
||||
local dropbear_authorized_keys="/etc/dropbear/initrd.authorized_keys"
|
||||
local sshcs_env="/etc/initcpio/sshcs_env"
|
||||
local dropbear_key_types=( "dss" "rsa" "ecdsa" )
|
||||
local dropbear_key_types=( "rsa" "ecdsa" "ed25519" )
|
||||
local dropbear_keyfile_prefix="/etc/dropbear/dropbear_"
|
||||
local dropbear_keyfile_suffix="_host_key"
|
||||
local openssh_keyfile_prefix="/etc/ssh/ssh_host_"
|
||||
@@ -53,6 +53,9 @@ build() {
|
||||
sshcs_check_keys
|
||||
|
||||
add_checked_modules "/drivers/net/"
|
||||
# Note: parts of this script (modules/binaries added) are the same than the
|
||||
# 'encrypt' install script (/usr/lib/initcpio/install/encrypt) which is the
|
||||
# nominal one to deal with encrypted volumes at boot time.
|
||||
add_module dm-crypt
|
||||
# Note: crypto modules are necessary
|
||||
if [ -n "${CRYPTO_MODULES}" ]; then
|
||||
@@ -79,9 +82,9 @@ build() {
|
||||
|
||||
# SSH-related files
|
||||
add_file "${dropbear_authorized_keys}" "/root/.ssh/authorized_keys"
|
||||
add_file "/etc/dropbear/dropbear_rsa_host_key"
|
||||
add_file "/etc/dropbear/dropbear_dss_host_key"
|
||||
add_file "/etc/dropbear/dropbear_ecdsa_host_key"
|
||||
for keytype in "${dropbear_key_types[@]}"; do
|
||||
add_file "${dropbear_keyfile_prefix}${keytype}${dropbear_keyfile_suffix}"
|
||||
done
|
||||
|
||||
# cryptsetup-related files
|
||||
add_file "${etc_crypttab}"
|
||||
@@ -90,6 +93,11 @@ build() {
|
||||
add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
|
||||
add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
|
||||
|
||||
# At least with LUKS v2 volumes, cryptsetup calls pthread_cancel(), which
|
||||
# dlopen()s libgcc_s.so.1.
|
||||
# See the nominal 'encrypt' module, and similar/related bug reports (e.g.
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=950254).
|
||||
add_binary "/usr/lib/libgcc_s.so.1"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
@@ -113,8 +121,8 @@ initrd shell):
|
||||
- default (and minimum value): 2 minutes
|
||||
- negative value to deactivate
|
||||
|
||||
Each SSH server key ('dropbear_rsa_host_key', 'dropbear_dss_host_key' and
|
||||
'dropbear_ecdsa_host_key' in '/etc/dropbear' folder) is imported from OpenSSH
|
||||
Each SSH server key ('dropbear_rsa_host_key', 'dropbear_ecdsa_host_key' and
|
||||
'dropbear_ed25519_host_key' in '/etc/dropbear' folder) is imported from OpenSSH
|
||||
if present or generated if missing. Fingerprints are displayed upon building
|
||||
the initramfs image.
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user