CIFRAR tus DATOS en LINUX con LUKS y YUBIKEY (FIDO2) | Nivel Paranoico
GUÍA DEFINITIVA: CIFRADO LUKS2 CON YUBIKEY (FIDO2) EN DEBIAN 13
En este tutorial aprenderás a elevar la seguridad de tus datos al "nivel paranoico" utilizando LUKS2 y autenticación por hardware con YubiKey. Veremos cómo configurar volúmenes cifrados utilizando el estándar moderno FIDO2 a través de systemd-cryptenroll.
Enlace al material en YouTube:
👉 https://youtu.be/2x6PLFOR9jQ
1. INSTALACIÓN DE PAQUETES ESENCIALES
Primero, instalamos las herramientas necesarias en Debian 13 para gestionar FIDO2 y la YubiKey:
sudo apt update && sudo apt install -y systemd-cryptsetup fido2-tools yubikey-manager yubikey-luks
ESCENARIO A: CIFRADO CON ARCHIVO CLAVE (KEYFILE) + YUBIKEY
PASO 1: CREAR EL ARCHIVO CLAVE (KEYFILE)
Generamos un archivo con 4KB de datos aleatorios:
sudo dd if=/dev/urandom of=/home/haymetk/fichero.bin bs=1024 count=4
PASO 2: CREAR EL CONTENEDOR (IMAGEN DE DISCO)
Creamos un archivo de 2GB que actuará como nuestro volumen cifrado:
dd if=/dev/zero of=/home/haymetk/Informacion.img bs=1M count=2048 status=progress
PASO 3: CIFRAR EL VOLUMEN CON LUKS2 (MÁXIMA PROTECCIÓN)
Aplicamos el cifrado AES-512 con Argon2id:
sudo cryptsetup luksFormat --type luks2 \
--cipher aes-xts-plain64 \
--key-size 512 \
--hash sha512 \
--pbkdf argon2id \
--pbkdf-memory 1048576 \
--pbkdf-parallel 4 \
--key-file /home/haymetk/fichero.bin \
/home/haymetk/Informacion.img
PASO 4: CONFIGURACIÓN DEL SISTEMA DE ARCHIVOS
Abrimos el volumen, le damos formato y preparamos el punto de montaje:
# Abrir volumen con el keyfile
sudo cryptsetup open /home/haymetk/Informacion.img informacion --key-file /home/haymetk/fichero.bin
# Dar formato ext4
sudo mkfs.ext4 /dev/mapper/informacion
# Crear punto de montaje y asignar permisos al usuario haymetk
sudo mkdir -p /mnt/informacion
sudo mount /dev/mapper/informacion /mnt/informacion
sudo chown haymetk:haymetk /mnt/informacion
chmod 700 /mnt/informacion
PASO 5: ASOCIAR LA YUBIKEY AL VOLUMEN
Vinculamos el token físico FIDO2 al volumen cifrado:
sudo systemd-cryptenroll \
--unlock-key-file=/home/haymetk/fichero.bin \
--fido2-device=auto \
--fido2-with-client-pin=no \
/home/haymetk/Informacion.img
ESCENARIO B: CIFRADO CON CONTRASEÑA + YUBIKEY
PASO 1: CIFRAR EL VOLUMEN USANDO CONTRASEÑA
sudo cryptsetup luksFormat --type luks2 \
--cipher aes-xts-plain64 \
--key-size 512 \
--hash sha512 \
--pbkdf argon2id \
--pbkdf-memory 1048576 \
--pbkdf-parallel 4 \
/home/haymetk/Informacion.img
PASO 2: VINCULAR LA YUBIKEY USANDO LA CONTRASEÑA
sudo systemd-cryptenroll --fido2-device=auto --fido2-with-client-pin=no /home/haymetk/Informacion.img
OPERACIONES COMUNES Y MANTENIMIENTO
VERIFICAR LOS KEYSLOTS ASOCIADOS (VER LA YUBIKEY EN EL SLOT 1):
sudo cryptsetup luksDump /home/haymetk/Informacion.img
CERRAR EL VOLUMEN DE FORMA SEGURA:
sudo cryptsetup close informacion
ABRIR EL VOLUMEN USANDO ÚNICAMENTE LA YUBIKEY:
sudo cryptsetup open /home/haymetk/Informacion.img informacion --token-only
BORRADO SEGURO DEL KEYFILE (MODO PARANOICO):
sudo shred -u -z -n 3 /home/haymetk/fichero.bin
RECOMENDACIÓN FINAL:
Siempre mantén un método de respaldo (segunda YubiKey o contraseña) vinculado a tu volumen. Si pierdes tu única YubiKey y borraste el Keyfile, la información será irrecuperable.
Si este contenido te ha sido útil, considera apoyarme en Patreon para seguir creando más guías y tutoriales sobre Linux:
❤️ Patreon:
👉 https://www.patreon.com/HAYMETK
¡Gracias por tu apoyo y nos leemos en el próximo artículo!
Comentarios
Publicar un comentario