Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
slackware:initrd_ssh [2017/03/05 15:08] – Thomas | slackware:initrd_ssh [2017/03/09 11:55] – Thomas | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
==== Créer un initrd avec ssh pour déchiffrer la partition système à distance ==== | ==== Créer un initrd avec ssh pour déchiffrer la partition système à distance ==== | ||
+ | |||
+ | === Création de l' | ||
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 : | 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 : | ||
Ligne 8: | Ligne 10: | ||
Avant d' | Avant d' | ||
+ | - Tout d' | ||
- Dans votre fichier / | - Dans votre fichier / | ||
- Créer votre initrd.gz comme vous avez l' | - Créer votre initrd.gz comme vous avez l' | ||
- | - | + | - Copier la commande dropbearmulti dans / |
+ | cp $PKG/ | ||
+ | ln -s dropbearmulti dropbear | ||
+ | ln -s dropbearmulti dropbearkey</ | ||
+ | - Créer une bannière (optionnelle). Vous pouvez y saisir les commandes dont vous aurez besoin pour déchiffrer votre partition et poursuivre le démarrage de l'OS : < | ||
+ | - L' | ||
+ | - Copier votre fichier /etc/shadow (uniquement la ligne root) car il contient le mot de passe à saisir : < | ||
+ | - Créer le fichier / | ||
+ | echo $$ > / | ||
+ | echo "###########################################" | ||
+ | echo "### | ||
+ | echo "###########################################" | ||
+ | echo "Press enter to continue booting:" | ||
+ | read INPUT</ | ||
+ | - Créer le fichier / | ||
+ | LUKSDEV=sda2 | ||
+ | |||
+ | PATH="/ | ||
+ | |||
+ | # unlock needed devices | ||
+ | cryptsetup luksOpen / | ||
+ | echo "/ | ||
+ | |||
+ | # kill bootlock | ||
+ | kill $(cat / | ||
+ | - Créer le fichier / | ||
+ | # initialize network interfaces for ssh boot | ||
+ | / | ||
+ | / | ||
+ | - Créer le fichier / | ||
+ | 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' | ||
+ | # Right now, it's configured for a static ip. Dhcp | ||
+ | # is within the possibilities, | ||
+ | # 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 "### | ||
+ | echo "###########################################" | ||
+ | echo " | ||
+ | ifconfig lo 127.0.0.1 | ||
+ | echo " | ||
+ | ifconfig $INET up $IP | ||
+ | echo " | ||
+ | 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 "### | ||
+ | echo "###########################################" | ||
+ | echo " | ||
+ | dropbearkey -t dss -f / | ||
+ | dropbearkey -t rsa -f / | ||
+ | dropbearkey -t ecdsa -f / | ||
+ | dropbear -b / | ||
+ | |||
+ | # 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 "### | ||
+ | echo "###############################################" | ||
+ | killall dropbear | ||
+ | sleep 1 | ||
+ | |||
+ | # Now shut down the network so it doesn' | ||
+ | # I'm not sure this is needed, but I've read reports of network issues because the | ||
+ | # regular boot process couldn' | ||
+ | # 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</ | ||
+ | - Rendre ces fichiers exécutables :< | ||
+ | - Ajouter la ligne "/ | ||
+ | # 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/udevd --daemon --resolve-names=never | ||
+ | / | ||
+ | / | ||
+ | /udev.sh | ||
+ | else | ||
+ | [ " | ||
+ | fi</ | ||
+ | - Ajouter la ligne "/ | ||
+ | if [ -x / | ||
+ | / | ||
+ | |||
+ | # Determine if we have to use a LUKS keyfile: | ||
+ | if [ ! -z " | ||
+ | - Recréer votre initrd.gz sans l' | ||
+ | - Relancer lilo |