-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup a cryptroot-installation including necessary steps for unlockin…
…g via ssh after reboot
- Loading branch information
Showing
5 changed files
with
244 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
NETWORK_STRING='ip={{ public_ip }}::{{ hetzner_crypt_network_gatewayv4 }}:255.255.255.255:{{ hetzner_hostname }}:{{ hetzner_crypt_network_interface }}:none rd.route={{ hetzner_crypt_network_gatewayv4 }}\/32:{{ hetzner_crypt_network_gatewayv4 }}:{{ hetzner_crypt_network_interface }}' | ||
|
||
dnf copr enable uriesk/dracut-crypt-ssh -y | ||
dnf install -y epel-release | ||
dnf install -y dracut-crypt-ssh | ||
|
||
echo "generating hostkeys" | ||
ssh-keygen -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key | ||
ssh-keygen -t ecdsa -N '' -f /etc/ssh/ssh_host_ecdsa_key | ||
ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_ed25519_key | ||
|
||
echo adjusting kernel cmdline for early network | ||
sed -i '/^GRUB_CMDLINE_LINUX="/ {s/\<quiet\>//g;s/"$/ rd.neednet=1 '"$NETWORK_STRING"'"/;}' /etc/default/grub | ||
|
||
echo rebuilding grub.cfg | ||
grub2-mkconfig --output /boot/grub2/grub.cfg | ||
|
||
echo creating dracut/crypt-ssh.conf | ||
cat > /etc/dracut.conf.d/crypt-ssh.conf << EOT | ||
# NOTE: The defaults in this file MUST be carefully read and understood before using this module! | ||
# The defaults may NOT be appropriate for your site. Carefully review and understand your threat model | ||
# (ie, what attack scenarios you are protecting yourself against) and adjust accordingly! | ||
# | ||
# The port to run the ssh daemon on | ||
# Default: 222 | ||
dropbear_port="{{ hetzner_crypt_network_ssh_port }}" | ||
# Where to get the RSA and/or ECDSA keys for dropbear, options are: | ||
# GENERATE: generate a new one for each initrd run, the public key will be printed during the dracut build process | ||
# and on boot | ||
# SYSTEM: use (convert) the host key from the host system's SSH daemon. This will make the initrd ssh indistinguishable | ||
# from the running system - this may be a security risk, depending on your threat model, but simplifies | ||
# your client-side ssh configuration | ||
# /path/to/openssh_key: an absolute path to a host key, in OpenSSH format as generated by ssh-keygen. | ||
# A public key with '.pub' ending must be present too. | ||
# | ||
# It is recommend that you use the system one, or supply your own. If using the system key, be aware that an attacker | ||
# that can access your initrd could use the host key to impersonate the running system. This could allow them to attempt | ||
# an MITM attack. | ||
# | ||
# Default: GENERATE | ||
# dropbear_rsa_key="GENERATE" | ||
# dropbear_ecdsa_key="GENERATE" | ||
# dropbear_ed25519_key="GENERATE" | ||
#dropbear_rsa_key="SYSTEM" | ||
#dropbear_ecdsa_key="SYSTEM" | ||
#dropbear_ed25519_key="SYSTEM" | ||
# Location of the list of authorized public keys that can log into the initrd ssh daemon | ||
# Defaults to the authorized_keys list for root. It may be advantageous to use a different authorized_keys list | ||
# so that users/machines that can unlock the machine are not necessarily given full root access after boot. | ||
# Note that root access to the initrd does give an attacker means to provide themselves with root access after boot, | ||
# especially if they hold the encryption keys to the root drive - choose carefully! | ||
# | ||
# Default: /root/.ssh/authorized_keys | ||
dropbear_acl="/root/.ssh/authorized_keys" | ||
# Users wishing to unlock LUKS volumes remotely using the 'unlock' helper will need cryptsetup available in the initramfs. | ||
# Uncomment the below line to make sure that the application is available when needed. | ||
# | ||
install_items+=" /sbin/cryptsetup " | ||
EOT | ||
|
||
echo rebuilding initramfs | ||
dracut -v --force --kver="$(ls /lib/modules)" |
This file contains 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