This commit is contained in:
Dominik Moritz Roth 2025-08-18 01:35:27 +02:00
parent ab251d723f
commit 97c296da97

View File

@ -192,29 +192,33 @@ systemctl enable clevis-luks-askpass.path || true
echo "[+] Configuring tinyssh for remote unlock..." echo "[+] Configuring tinyssh for remote unlock..."
# Create tinyssh dracut module # Create tinyssh dracut module
mkdir -p /usr/lib/dracut/modules.d/60tinyssh mkdir -p /usr/lib/dracut/modules.d/90tinyssh
cat > /usr/lib/dracut/modules.d/60tinyssh/module-setup.sh << 'EOF' cat > /usr/lib/dracut/modules.d/90tinyssh/module-setup.sh << 'EOF'
#!/bin/bash #!/bin/bash
check() { check() {
require_binaries tinysshd tinyssh-keyconvert || return 1 require_binaries tinysshd tinysshd-makekey
return 0
} }
depends() { depends() {
echo network echo network
return 0
} }
install() { install() {
inst_multiple tinysshd tinysshd-makekey inst_multiple tinysshd tinysshd-makekey
mkdir -p "$initdir/etc/tinyssh"
inst_dir /etc/tinyssh
# Copy authorized keys # Copy authorized keys
[ -f /etc/tinyssh/authorized_keys ] && inst /etc/tinyssh/authorized_keys /etc/tinyssh/authorized_keys if [[ -f /etc/tinyssh/authorized_keys ]]; then
inst /etc/tinyssh/authorized_keys /etc/tinyssh/authorized_keys
fi
# Copy host keys # Copy host keys directory
[ -d /etc/tinyssh/sshkeydir ] && inst /etc/tinyssh/sshkeydir /etc/tinyssh/ 2>/dev/null || true if [[ -d /etc/tinyssh/sshkeydir ]]; then
cp -r /etc/tinyssh/sshkeydir "$initdir/etc/tinyssh/"
fi
# Install startup script # Install startup script
inst_hook cmdline 60 "$moddir/tinyssh-start.sh" inst_hook cmdline 60 "$moddir/tinyssh-start.sh"
@ -225,7 +229,7 @@ install() {
} }
EOF EOF
cat > /usr/lib/dracut/modules.d/60tinyssh/tinyssh-start.sh << 'EOF' cat > /usr/lib/dracut/modules.d/90tinyssh/tinyssh-start.sh << 'EOF'
#!/bin/bash #!/bin/bash
info "Starting tinyssh SSH server on port 2222..." info "Starting tinyssh SSH server on port 2222..."
[ -d /etc/tinyssh ] || mkdir -p /etc/tinyssh [ -d /etc/tinyssh ] || mkdir -p /etc/tinyssh
@ -233,7 +237,7 @@ info "Starting tinyssh SSH server on port 2222..."
tinysshd -p 2222 /etc/tinyssh/sshkeydir & tinysshd -p 2222 /etc/tinyssh/sshkeydir &
EOF EOF
cat > /usr/lib/dracut/modules.d/60tinyssh/unlock-luks.sh << 'EOF' cat > /usr/lib/dracut/modules.d/90tinyssh/unlock-luks.sh << 'EOF'
#!/bin/bash #!/bin/bash
echo "Available LUKS devices:" echo "Available LUKS devices:"
ls /dev/mapper/luks-* 2>/dev/null ls /dev/mapper/luks-* 2>/dev/null
@ -243,7 +247,7 @@ echo "Then: exit"
/bin/bash /bin/bash
EOF EOF
chmod +x /usr/lib/dracut/modules.d/60tinyssh/*.sh chmod +x /usr/lib/dracut/modules.d/90tinyssh/*.sh
# Setup tinyssh # Setup tinyssh
mkdir -p /etc/tinyssh mkdir -p /etc/tinyssh
@ -255,7 +259,7 @@ tinysshd-makekey /etc/tinyssh/sshkeydir
# Configure dracut # Configure dracut
cat > /etc/dracut.conf.d/99-tinyssh.conf << 'EOF' cat > /etc/dracut.conf.d/99-tinyssh.conf << 'EOF'
add_dracutmodules+=" network 60tinyssh " add_dracutmodules+=" network tinyssh "
install_items+=" /etc/tinyssh/authorized_keys /etc/tinyssh/sshkeydir " install_items+=" /etc/tinyssh/authorized_keys /etc/tinyssh/sshkeydir "
EOF EOF