Ayant slackware installée sur une partition chiffrée via Luks, cette distribution propose deux possibilités pour la déchiffrer au démarrage de l'OS :
Grâce à cette page, j'ai pu créer un initrd permettant d'accéder à distance à la machine via ssh me permettant ainsi de déchiffrer la partition contenant slackware avec le mot de passe.
Avant d'expliquer la marche à suivre, je suppose que vous savez déjà créer un initrd avec les modules et les options nécessaires pour être en mesure de déchiffrer votre partition slackware via la clé USB ou le mot de passe. Voici la marche à suivre :
cd /boot/initrd-tree/bin cp $PKG/usr/bin/dropbearmulti . ln -s dropbearmulti dropbear ln -s dropbearmulti dropbearkey
vi /boot/initrd-tree/etc/dropbear/banner
root:x:0:0::/root:/bin/sh
grep ^root /etc/shadow > /boot/initrd-tree/etc/shadow
echo $$ > /bootlock.pid echo "###########################################" echo "### Wait for user input ###" echo "###########################################" echo "Press enter to continue booting:" read INPUT
LUKSDEV=sda2 PATH="/sbin:/bin:/usr/sbin:/usr/bin" # unlock needed devices cryptsetup luksOpen /dev/${LUKSDEV} luks${LUKSDEV} || exit 1 echo "/dev/${LUKSDEV} unlocked" # kill bootlock kill $(cat /bootlock.pid)
# initialize network interfaces for ssh boot /sbin/udevadm trigger --action='add' --subsystem-match='net' /sbin/udevadm settle --timeout=10
INET=eth0 IP=192.168.0.71 GATEWAY=192.168.0.1 # init network # Obviously, you should put in the correct interfaces # here, and edit the ip addresses. It's easiest to # use a different ip address than the pc usually # has, because the host keys are different and ssh # will die over that, unless you explicitly tell it # not to EVERY SINGLE TIME. This way, ssh will not # see this as the same host and there's no problem. # Right now, it's configured for a static ip. Dhcp # is within the possibilities, I just don't use it. # It will most likely be difficult though, as it's # not automatically included in the initrd. Do # yourself a favor and just configure it statically. # ;) echo "###########################################" echo "### Initializing network ###" echo "###########################################" echo "-------- Bringing up lo on 127.0.0.1" ifconfig lo 127.0.0.1 echo "-------- Bringing up $INET on $IP" ifconfig $INET up $IP echo "-------- Adding $GATEWAY as default gw" route add -net 127.0.0.0 netmask 255.0.0.0 lo route add default gw $GATEWAY # start ssh # This kinda speaks for itself. You could set a few # options for dropbear if you wanted (-s to disable # password login for example). echo "###########################################" echo "### Starting ssh daemon ###" echo "###########################################" echo "-------- Starting daemon on port 22" dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key dropbear -b /etc/dropbear/banner # lock system until user provides input, or this script is killed (via ssh) bootlock # We don't need ssh anymore - kill off dropbear echo "###############################################" echo "### Shut down network ###" echo "###############################################" killall dropbear sleep 1 # Now shut down the network so it doesn't interfere with the normal booting process # I'm not sure this is needed, but I've read reports of network issues because the # regular boot process couldn't overwrite the initial configuration. Seemed the safe # thing to do. Also, I don't like the idea of leaving the network open unprotected # (no firewall) any longer than I have to. ifconfig $INET down ifconfig lo down
chmod +x /boot/initrd-tree/{udev.sh,network.sh,bin/bootlock,bin/unlock}
# If udevd is available, use it to generate block devices # else use mdev to read sysfs and generate the needed devices if [ -x /sbin/udevd -a -x /sbin/udevadm ]; then /sbin/udevd --daemon --resolve-names=never /sbin/udevadm trigger --subsystem-match=block --action=add /sbin/udevadm settle --timeout=10 /udev.sh else [ "$DEVTMPFS" != "1" ] && mdev -s fi
if [ -x /sbin/cryptsetup ]; then /network.sh # Determine if we have to use a LUKS keyfile: if [ ! -z "$LUKSKEY" ]; then…