2021-11-13 23:02:45 +03:00
Personal ArchLinux package combining dropbear and cryptsetup in initramfs for unlocking LUKS-encrypted devices either locally (boot console) or remotely over SSH.
2017-09-03 22:34:10 +03:00
The code was reworked from legacy dropbear_initrd_encrypt AUR package.
2014-05-20 00:46:59 +04:00
## Installation
2017-09-03 22:34:10 +03:00
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
2020-07-14 17:22:54 +03:00
Notes:
* `rsa` and `ed25519` types are also handled
* OpenSSH keys must be in `PEM` format for `dropbearconvert` to properly work
2014-05-20 00:46:59 +04:00
2021-08-16 00:07:37 +03:00
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
2014-05-20 00:46:59 +04:00
## Configuration
As explained upon installation, the following things need to be done:
2017-09-03 22:34:10 +03:00
* add the authorized SSH public key to `/etc/dropbear/initrd.authorized_keys`
2017-06-25 19:22:53 +03:00
* add the `ip=` kernel command parameter to the bootloader configuration (see https://wiki.archlinux.org/index.php/Mkinitcpio#Using_net)
2017-09-03 22:34:10 +03:00
- 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`
2021-10-24 18:56:05 +03:00
- also see https://git.kernel.org/pub/scm/libs/klibc/klibc.git/tree/usr/kinit/ipconfig/README.ipconfig
2017-06-25 19:22:53 +03:00
* in the `HOOKS` section of `/etc/mkinitcpio.conf` , add `ssh-cryptsetup` before `filesystems` ; then rebuild the initramfs: `mkinitcpio -p linux`
2017-09-03 22:34:10 +03:00
- 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`
2014-05-20 00:46:59 +04:00
The LUKS-encrypted devices to unlock are derived from `/etc/crypttab` .
2014-05-21 00:39:32 +04:00
2021-11-13 23:02:45 +03:00
Some options can be set in `/etc/initcpio/sshcs_env` (file is sourced in initramfs shell):
2017-06-25 21:07:07 +03:00
* `sshcs_opt_debug` : whether to be more verbose about ongoing actions
2021-11-13 23:02:45 +03:00
- default: `0`
2017-06-25 21:07:07 +03:00
- any non-zero value to enable
2021-11-13 23:02:45 +03:00
* `sshcs_opt_net_wol` : Wake-on-LAN option to set on network device
- default: `g` (MagicPacket™)
- usually WOL is disabled once in initramfs shell
- set empty to not change network device WOL setting
2017-06-25 19:22:53 +03:00
* `sshcs_opt_timeout_ipconfig` : time (in seconds) to configure IP
2021-11-13 23:02:45 +03:00
- default: `10`
2017-06-25 19:22:53 +03:00
* `sshcs_opt_listen` : SSH listening port
2021-11-13 23:02:45 +03:00
- default: `22`
2017-06-25 19:22:53 +03:00
* `sshcs_opt_timeout_poweroff` : time (in seconds) to unlock devices before automatic powering off
2021-11-13 23:02:45 +03:00
- default (and minimum value): `120` (2 minutes)
2017-06-25 19:22:53 +03:00
- negative value to deactivate
2021-11-13 23:02:45 +03:00
* `sshcs_opt_use_shell` : whether to start a full `ash` shell
- default: `0`
- `1` to enable
- when disabled (the default), a script to unlock devices is executed instead
2014-05-21 00:39:32 +04:00
2014-05-20 00:46:59 +04:00
For example:
2015-11-22 20:53:37 +03:00
sshcs_opt_timeout_ipconfig=30
2014-05-20 00:46:59 +04:00
sshcs_opt_listen=2222
2014-05-21 00:39:32 +04:00
sshcs_opt_timeout_poweroff=-1
2021-11-13 23:02:45 +03:00
sshcs_opt_use_shell=1
2014-05-20 00:46:59 +04:00
2017-06-25 19:22:53 +03:00
## Building notes
1. Modify the sources (features in `src` , and/or package building files)
2. If `src` was modified
2021-11-13 23:02:45 +03:00
* bump `pkgver` in `PKGBUILD`
* archive the `src` folder in `$pkgname-$pkgver.tar.xz` file; e.g.: `tar -cJf initrd-ssh-cryptsetup-$(grep "^pkgver=" PKGBUILD | cut -d'=' -f2).tar.xz src`
2017-06-25 19:22:53 +03:00
* upload the archive on the online repository (pointed by `PKGBUILD` )
2018-03-14 00:05:48 +03:00
3. Update ChangeLog
4. Update `PKGBUILD`
2021-11-13 23:02:45 +03:00
* bump `pkgrel` if only building files were modified
2021-11-12 20:03:46 +03:00
* refresh `sha256sums` with `updpkgsums` if necessary
- or manually, based on `sha256sum initrd-ssh-cryptsetup-*.tar.xz initrd-ssh-cryptsetup.install` output
2018-03-14 00:05:48 +03:00
5. Delete generated archive file if any