008.) install Dropbear-initramfs to unlock LUKS via SSH
- # apt install dropbear-initramfs dropbear busybox
- # nano /etc/dropbear-initramfs/authorized_keys
- put RSA pubkey in there:
- change SSH port:
# nano /etc/dropbear-initramfs/config
- replace the line "#DROPBEAR_OPTION" with "DROPBEAR_OPTIONS="-p 10022 -j -k -c cryptroot-unlock""
which will make dropbear use port 10022 instead of 22 and then automatically ask for the LUKS password
- # nano /etc/initramfs-tools/initramfs.conf
- change the line "DEVICE=" to "DEVICE=eno2" so only the management NIC is used.
- there is also this line to setup network configuration:
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>
- so use something like: "
ip=192.168.0.2::192.168.0.1:255.255.255.0:Hypervisor:eno2:off:192.168.0.1:192.168.0.1:
"
- # update-initramfs -u
- reboot server and look if unlocking using SSH works (make sure to connect to port 10022 and not the default port 22)
- looks like static IPs aren't working but DHCP does. So I setup the router to always give the dropbears MAC to same IP
Edit:
I switched to VLANs and now everything is only working using a VLAN trunk. Because initramfs by default can't use VLANs you need to setup the hooks from this Github repo first: "
https://github.com/skom91/initramfs-tools-network-hook". For that you need to do:
- # nano /etc/initramfs-tools/scripts/local-top/vlan
insert content of "
https://github.com/skom91/initramfs...er/etc/initramfs-tools/scripts/local-top/vlan"
- # nano /etc/initramfs-tools/scripts/local-bottom/vlan
insert content of "
https://github.com/skom91/initramfs...etc/initramfs-tools/scripts/local-bottom/vlan"
- # nano /etc/initramfs-tools/hooks/vlan
insert content of "
https://github.com/skom91/initramfs-tools-network-hook/blob/master/etc/initramfs-tools/hooks/vlan"
- set rights:
# chmod 755 /etc/initramfs-tools/scripts/local-top/vlan
# chmod 755 /etc/initramfs-tools/scripts/local-bottom/vlan
# chmod 755 /etc/initramfs-tools/hooks/vlan
- # nano /etc/initramfs-tools/initramfs.conf
Instead of this lines...
DEVICE=eno2
"
ip=192.168.0.2::192.168.0.1:255.255.255.0:Hypervisor:eno2:off:192.168.0.1:192.168.0.1:
"
... use these:
VLAN="ens5:43"
IP=192.168.0.2::192.168.0.1:255.255.255.0::ens5.43:off
With this initramfs will use the interface ens5 with tagged VLANID 43 which will result in a interface "ens5.43" and this will be assiged the static IP "192.168.0.2" with a subnetmask of "255.255.255.0" and "192.168.0.1" as gateway
- rebuild initramfs:
# update-initramfs -u