quarks/sys-kernel/dracut/files/027-crypt-ssh.patch

77 lines
2.6 KiB
Diff
Raw Normal View History

commit 2a662251cf8d8163d5fbd42cd4c08329d58f2486
2013-03-30 20:09:46 +00:00
Author: Stefan Reimer <it@startux.de>
Date: Wed Apr 3 23:18:19 2013 -0700
2013-03-30 20:09:46 +00:00
Initial version of the crypt-ssh module
2013-03-30 20:09:46 +00:00
diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh
index 9665e48..2d81684 100755
2013-03-30 20:09:46 +00:00
--- a/modules.d/90crypt/cryptroot-ask.sh
+++ b/modules.d/90crypt/cryptroot-ask.sh
@@ -146,12 +146,26 @@ fi
2013-03-30 20:09:46 +00:00
if [ $ask_passphrase -ne 0 ]; then
luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen"
- ask_for_password --ply-tries 5 \
- --ply-cmd "$luks_open -T1 $device $luksname" \
- --ply-prompt "Password ($device)" \
- --tty-tries 1 \
- --tty-cmd "$luks_open -T5 $device $luksname"
- unset luks_open
+ port=22001
2013-03-30 20:09:46 +00:00
+
+ if getargbool 0 rd.luks.ssh; then
+ # Setup authorized_key file
+ echo -n "command=\"$luks_open -T5 $device $luksname && rm -f /root/.ssh/key.pub \" " > /root/.ssh/authorized_keys
+ cat /root/.ssh/key.pub >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys
+ echo "Starting SSH server on port $port"
+ /usr/sbin/dropbear -p $port -m -j -k -s
+ while [ -f /root/.ssh/key.pub ]; do
+ sleep 1
+ done
+ kill $(cat /var/run/dropbear.pid)
+ else
2013-03-30 20:09:46 +00:00
+ ask_for_password --ply-tries 5 \
+ --ply-cmd "$luks_open -T1 $device $luksname" \
+ --ply-prompt "Password ($device)" \
+ --tty-tries 1 \
+ --tty-cmd "$luks_open -T5 $device $luksname"
+ fi
+ unset luks_open port
2013-03-30 20:09:46 +00:00
fi
unset device luksname luksfile
2013-03-30 20:09:46 +00:00
diff --git a/modules.d/92crypt-ssh/module-setup.sh b/modules.d/92crypt-ssh/module-setup.sh
new file mode 100644
index 0000000..ac0785b
2013-03-30 20:09:46 +00:00
--- /dev/null
+++ b/modules.d/92crypt-ssh/module-setup.sh
@@ -0,0 +1,27 @@
2013-03-30 20:09:46 +00:00
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# Author: Stefan Reimer
+# Date: 2013-Mar-24
+
+check() {
+ [ -x /usr/sbin/dropbear ]
+}
+
+depends() {
+ echo "network crypt"
+ return 0
+}
+
+install() {
+ #Install dropbear incl. keys
+ mkdir -p /etc/dropbear
+ [ -r /etc/dropbear/dropbear_dss_host_key ] || /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key > /dev/null
+ [ -r /etc/dropbear/dropbear_rsa_host_key ] || /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key > /dev/null
2013-03-30 20:09:46 +00:00
+
+ inst /usr/sbin/dropbear
+ inst /etc/dropbear/dropbear_dss_host_key
+ inst /etc/dropbear/dropbear_rsa_host_key
+ [ -r /root/.ssh/authorized_keys ] && inst /root/.ssh/authorized_keys /root/.ssh/key.pub
2013-03-30 20:09:46 +00:00
+}