Created
January 13, 2017 22:01
-
-
Save darth-veitcher/00faac9eb95ba96a302da1e0a32006a7 to your computer and use it in GitHub Desktop.
cryptroot unlock via dropbear
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://chicagolug.org/news/2015-10-09-remotely-unlock-encrypted-server-with-dropbear.html | |
# Quit the Ubuntu graphical splash screen. This is necessary for cryptroot | |
# to work right. The server will fall back to a non-graphical unlock | |
# screen. | |
plymouth --quit | |
count=0 | |
# Looping gives us some control over the number of unlock attempts. | |
while ! ( ls /dev/mapper/ | grep root > /dev/null ); do | |
if [ $count -gt 0 ]; then | |
exit 1 | |
fi | |
sleep 3 | |
count=$(( count + 1 )) | |
# This script detects your encryption and LVM configuration and | |
# prompts the user to unlock their encrypted hard disks. | |
/scripts/local-top/cryptroot | |
done | |
# Kill these programs to keep 'init' moving. | |
if ( ps | grep cryptsetup | grep askpass > /dev/null ); then | |
kill -9 $(ps | grep cryptsetup | grep askpass | awk '{print $1}') | |
fi | |
if ( ps | grep /bin/sh | grep "sh -i" > /dev/null ); then | |
kill -9 $(ps | grep /bin/sh | grep "sh -i" | awk '{print $1}') | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment