Luks
De Linuxmemo.
(Différences entre les versions)
(→Auto mount) |
|||
(15 versions intermédiaires masquées) | |||
Ligne 1 : | Ligne 1 : | ||
[[Catégorie:Linux sysadmin]] | [[Catégorie:Linux sysadmin]] | ||
LUKS, pour Linux Unified Key Setup (sous Linux:cryptsetup, utilisant dm-crypt) | LUKS, pour Linux Unified Key Setup (sous Linux:cryptsetup, utilisant dm-crypt) | ||
- | + | ==Initialisation== | |
+ | Creation d'une partition type "83 linux": | ||
Lsblk | Lsblk | ||
Ligne 10 : | Ligne 11 : | ||
w | w | ||
+ | Initialisation du chiffrement: | ||
cryptsetup luksFormat /dev/sdb1 | cryptsetup luksFormat /dev/sdb1 | ||
+ | Mappage de la partition avec "device-mapper" et le module "crypt": | ||
cryptsetup open /dev/sdb1 sdb1-crypt | cryptsetup open /dev/sdb1 sdb1-crypt | ||
+ | |||
+ | Formatage de la partition: | ||
+ | mkfs.ext4 -L backup-crypt /dev/mapper/sdb1-crypt | ||
+ | |||
+ | Démontage propre: | ||
+ | cryptsetup close /dev/mapper/sdb1-crypt | ||
+ | |||
+ | ==utilisation manuelle== | ||
+ | cryptsetup open /dev/sdb1 sdb1-crypt | ||
+ | mount /dev/mapper/sdb1-crypt /backup | ||
+ | |||
+ | ==Auto mount== | ||
+ | Savoir si il existe déjà une cle | ||
+ | cryptsetup luksDump /dev/sdb1 | ||
+ | |||
+ | Créer un fichier cle | ||
+ | dd if=/dev/random bs=32 count=1 of=/etc/lukskey | ||
+ | chmod 400 /etc/lukskey | ||
+ | xxd /etc/lukskey | ||
+ | Ajouter la cle au disque /partition | ||
+ | cryptsetup luksAddKey /dev/sdb1 /etc/lukskey | ||
+ | lier la cle au disque /partition | ||
+ | cryptsetup luksDump /dev/sdb1|grep UUID | ||
+ | vim etc/crypttab | ||
+ | sdb1_crypt UUID=658e8adb-778a-4bd6-b636-a0c5f7b353bb /etc/lukskey luks,discard | ||
+ | Montage automatique | ||
+ | vim /etc/fstab | ||
+ | /dev/mapper/sdb1_crypt /backup ext4 errors=remount-ro 0 1 | ||
+ | |||
+ | ==Automatisme== | ||
+ | cryptdisks_start labelvolume | ||
+ | cryptdisks_stop labelvolume | ||
+ | lit le fichier "/etc/crypttab" | ||
+ | |||
+ | *The first field, "target, describes the mapped device name" | ||
+ | *The second field, source device UUID=<luks_uuid> - cryptsetup luksDump /dev/sdb1|grep UUID | ||
+ | *The third field, key file or "none" | ||
+ | *The fourth field, options |
Version actuelle en date du 28 janvier 2020 à 12:55
LUKS, pour Linux Unified Key Setup (sous Linux:cryptsetup, utilisant dm-crypt)
Sommaire |
[modifier] Initialisation
Creation d'une partition type "83 linux":
Lsblk fdisk /dev/sdb o n p w
Initialisation du chiffrement:
cryptsetup luksFormat /dev/sdb1
Mappage de la partition avec "device-mapper" et le module "crypt":
cryptsetup open /dev/sdb1 sdb1-crypt
Formatage de la partition:
mkfs.ext4 -L backup-crypt /dev/mapper/sdb1-crypt
Démontage propre:
cryptsetup close /dev/mapper/sdb1-crypt
[modifier] utilisation manuelle
cryptsetup open /dev/sdb1 sdb1-crypt mount /dev/mapper/sdb1-crypt /backup
[modifier] Auto mount
Savoir si il existe déjà une cle
cryptsetup luksDump /dev/sdb1
Créer un fichier cle
dd if=/dev/random bs=32 count=1 of=/etc/lukskey chmod 400 /etc/lukskey xxd /etc/lukskey
Ajouter la cle au disque /partition
cryptsetup luksAddKey /dev/sdb1 /etc/lukskey
lier la cle au disque /partition
cryptsetup luksDump /dev/sdb1|grep UUID vim etc/crypttab sdb1_crypt UUID=658e8adb-778a-4bd6-b636-a0c5f7b353bb /etc/lukskey luks,discard
Montage automatique
vim /etc/fstab /dev/mapper/sdb1_crypt /backup ext4 errors=remount-ro 0 1
[modifier] Automatisme
cryptdisks_start labelvolume cryptdisks_stop labelvolume
lit le fichier "/etc/crypttab"
- The first field, "target, describes the mapped device name"
- The second field, source device UUID=<luks_uuid> - cryptsetup luksDump /dev/sdb1|grep UUID
- The third field, key file or "none"
- The fourth field, options