All Projects → ceremcem → unlock-luks-partition

ceremcem / unlock-luks-partition

Licence: other
Unlock a LUKS partition via SSH

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to unlock-luks-partition

LUKS-OPs
A bash script to automate the most basic usage of LUKS volumes in Linux VPS
Stars: ✭ 30 (-3.23%)
Mutual labels:  luks, luks-partition
arch-config
Scripts and Ansible playbook to setup Arch Linux on ZFS.
Stars: ✭ 36 (+16.13%)
Mutual labels:  boot, luks
pam panic
A PAM module that protects sensitive data and provides a panic function for emergency situations. Authentication through passwords or removable media.
Stars: ✭ 35 (+12.9%)
Mutual labels:  luks, luks-partition
Tow-Boot
An opinionated distribution of U-Boot. — https://matrix.to/#/#Tow-Boot:matrix.org?via=matrix.org
Stars: ✭ 338 (+990.32%)
Mutual labels:  boot
luks2crypt
Manage linux luks client devices and escrow recovery keys to crypt-server
Stars: ✭ 32 (+3.23%)
Mutual labels:  luks
u2f-luks
No description or website provided.
Stars: ✭ 29 (-6.45%)
Mutual labels:  luks
TC1791 CAN BSL
CAN Bootstrap Loader (BSL) for Tricore AudoMAX (TC1791 and friends), including arbitrary read/write as well as compressed read functionality.
Stars: ✭ 25 (-19.35%)
Mutual labels:  boot
bootutils
Utilities to create bootable disks, remaster ISO images, make multiboot ISO images
Stars: ✭ 18 (-41.94%)
Mutual labels:  boot
bananapi-zero-ubuntu-base-minimal
BananaPi M2 Zero - Ubuntu Focal Base Minimal Image (Experimental) - U-Boot 2017.09 / Kernel 4.18.y / Kernel 4.19.y / Kernel 4.20.y / Kernel 5.3.y / Kernel 5.6.y / Kernel 5.7.y / Kernel 5.11.y
Stars: ✭ 77 (+148.39%)
Mutual labels:  boot
springboot-mongodb-security
Spring Boot, Security, and Data MongoDB Authentication Example
Stars: ✭ 22 (-29.03%)
Mutual labels:  boot
rpooler
A guided installation script for zfs rpools
Stars: ✭ 30 (-3.23%)
Mutual labels:  boot
node-beagle-boot
A node.js USB bootloader server for BeagleBone for booting it into mass storage mode
Stars: ✭ 17 (-45.16%)
Mutual labels:  boot
cljs-rails
Clojurescript integration for Rails inspired by webpack-rails
Stars: ✭ 41 (+32.26%)
Mutual labels:  boot
Multiboot-Toolkit
Create a bootable disk
Stars: ✭ 96 (+209.68%)
Mutual labels:  boot
MultiOS-USB
Boot operating systems directly from ISO files
Stars: ✭ 106 (+241.94%)
Mutual labels:  boot
ansible-archlinux
Automated arch linux desktop environment
Stars: ✭ 56 (+80.65%)
Mutual labels:  luks
debian-headless
Create a debian headless/remote installation image
Stars: ✭ 92 (+196.77%)
Mutual labels:  boot
spring-microservices
Spring Cloud Micro Services with Eureka Discovery, Zuul Proxy, OAuth2 Security, Hystrix CircuitBreaker, Sleuth Zipkin, ELK Stack Logging, Kafka, Docker and many new features
Stars: ✭ 114 (+267.74%)
Mutual labels:  boot
React-Springboot-App
Spring Boot is an open source Java-based framework used to create a micro Service. It is developed by Pivotal Team and is used to build stand-alone and production ready spring applications and React is a free and open-source front-end JavaScript library for building user interfaces based on UI components.
Stars: ✭ 22 (-29.03%)
Mutual labels:  boot
cryptctl
A disk encryption utility that helps setting up LUKS-based disk encryption using randomly generated keys, and keeps all keys on a dedicated key server.
Stars: ✭ 23 (-25.81%)
Mutual labels:  luks

Unlock LUKS Partition with SSH

Below instructions are for booting your SERVER by connecting and unlocking the encrypted partition via your CLIENT over SSH:

WARNING: Typing your crypto key over network might be secure (due to the secure nature of the SSH connection) as long as you are completely certain that the initramfs has not been subjugated so that there is no MITM attack taking place while you are typing your disk passphrase.

1. Install mandatory packages (on SERVER)

apt-get install dropbear initramfs-tools busybox

Check that Dropbear has disabled itself in /etc/default/dropbear

NO_START=1

2. Append your desired public keys into the SERVER's authorized_keys file

Just copy and paste your public key(s) into /etc/dropbear-initramfs/authorized_keys on SERVER

3. Create the unlock script

Create the following script as /etc/initramfs-tools/hooks/crypt_unlock.sh

#!/bin/sh

PREREQ="dropbear"

prereqs() {
  echo "$PREREQ"
}

case "$1" in
  prereqs)
    prereqs
    exit 0
  ;;
esac

. "${CONFDIR}/initramfs.conf"
. /usr/share/initramfs-tools/hook-functions

if [ "${DROPBEAR}" != "n" ] && [ -r "/etc/crypttab" ] ; then
cat > "${DESTDIR}/bin/unlock" << EOF
#!/bin/sh
if PATH=/lib/unlock:/bin:/sbin /scripts/local-top/cryptroot; then
kill \`ps | grep cryptroot | grep -v "grep" | awk '{print \$1}'\`
# following lines will be executed after the passphrase has been correctly entered
# kill the remote shell
kill -9 \`ps | grep "\-sh" | grep -v "grep" | awk '{print \$1}'\`
exit 0
fi
exit 1
EOF
  
  chmod 755 "${DESTDIR}/bin/unlock"
  
  mkdir -p "${DESTDIR}/lib/unlock"
cat > "${DESTDIR}/lib/unlock/plymouth" << EOF
#!/bin/sh
[ "\$1" == "--ping" ] && exit 1
/bin/plymouth "\$@"
EOF
  
  chmod 755 "${DESTDIR}/lib/unlock/plymouth"
  
  echo To unlock root-partition run "unlock" >> ${DESTDIR}/etc/motd
  
fi

Make it executable:

chmod +x /etc/initramfs-tools/hooks/crypt_unlock.sh

Create the cleanup script as /etc/initramfs-tools/scripts/init-bottom/cleanup.sh:

#!/bin/sh
echo "Killing dropbear"
killall dropbear
exit 0

...and make it executable:

chmod +x /etc/initramfs-tools/scripts/init-bottom/cleanup.sh

4. Create a static IP (or skip this step to use DHCP)

Edit /etc/initramfs-tools/initramfs.conf to add (or change) the line:

IP=192.168.1.254::192.168.1.1:255.255.255.0::eth0:off
format: 

    IP=${ip}::${gateway_ip}:${netmask}:[${hostname}]:${eth_device}:${autoconf}

([hostname] can be omitted)

In newer kernels eth0 is renamed to enp0s3 (or something like that). Check that out with ls /sys/class/net

5. Update initramfs

WARNING: Be careful if you directly edited /boot/grub/grub.cfg, since it will be overwritten by below command. You may end up with a broken boot sequence. See the important note.

update-initramfs -u

6. Test

  1. Reboot your server
  2. Connect to your server via ssh [email protected] [-i ~/.ssh/id_rsa]

Advanced configuration

Create a Reverse Tunnel

You may want your SERVER to connect your Link Up Server with SSH, create a reverse tunnel to its SSH Server, so you can connect your SERVER over your Link Up Server, which eliminates the need for firewall forwarding for above process.

(see reverse-tunnel-setup.md)

Run Dropbear on additional ports

(based on https://askubuntu.com/a/840067/371730)

  1. Define extra ports:

    --- /usr/share/initramfs-tools/scripts/init-premount/dropbear	2018-09-22 01:55:50.963967412 +0300
    +++ /usr/share/initramfs-tools/scripts/init-premount/dropbear	2018-09-22 01:56:04.091945164 +0300
    @@ -26,7 +26,7 @@
    -    exec /sbin/dropbear $DROPBEAR_OPTIONS -Fs
    +    exec /sbin/dropbear $DROPBEAR_OPTIONS -Fs -p 22 -p 80
  2. Update initramfs:

    update-initramfs -u
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].