Wiki Linux SMH

   

Flux RSS

Crypter Les Disques

Attention, toutes les manipulations indiquées ici sont risquées pour vos données! Avant de faire les manipulations suivantes, pensez à faire des sauvegardes.

1 - Cryptsetup

1.1 - Installation de l'outil

# apt-get install cryptsetup

1.2 - Chargement des modules

# modprobe aes
# modprobe dm_crypt
# modprobe dm_mod
  expliquer le principe et surtout LUKS, son intérêt et son utilisation

2 - Cryptage d'une partition lambda

Cas d'utilisation : on crypte une partition non sensible (ni /, /home, swap, etc)

Ici notre partition à crypter sera /dev/sda6. Elle est en ext3 et on désire la monter dans /mnt/stock.

2.1 - Création de la partition cryptée :

# cryptsetup luksFormat /dev/sda6

WARNING!
========
This will overwrite data on /dev/sda6 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase: 
Verify passphrase: 
Command failed: Failed to setup dm-crypt key mapping.
Check kernel for support for the aes-cbc-essiv:sha256 cipher spec and verify that /dev/sda6 contains at least 133 sectors
darkstar:/home/fritz# modprobe aes
darkstar:/home/fritz# modprobe dm_crypt
darkstar:/home/fritz# modprobe dm_mod
darkstar:/home/fritz# cryptsetup luksFormat /dev/sda6

WARNING!
========
This will overwrite data on /dev/sda6 irrevocably.

Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase: 
Verify passphrase: 
Command successful.

2.2 - Ouverture de la partition cryptée

# cryptsetup luksOpen /dev/sda6 stock
Enter LUKS passphrase: 
key slot 0 unlocked.
Command successful.

La partition est maintenant présente dans /dev/mapper/stock :

# ls -l /dev/mapper/
total 0
crw-rw---- 1 root root  10, 60 jan 10 10:32 control
brw-rw---- 1 root disk 254,  0 jan 10 10:36 stock

2.3 - Ajout d'une clé à la partition

LUKS permet d'avoir 8 clés pour la partition. Nous allons en créer une seconde par sécurité :

# cryptsetup luksAddKey /dev/sda6
Enter any LUKS passphrase: 
key slot 0 unlocked.
Enter new passphrase for key slot: 
Verify passphrase: 
Command successful.

2.4 - Affichage des informations de la partition cryptée.

Afin de vérifier (entre autres) le nombre de slots utilisés, on peut afficher les informations de la partition cryptée :

# cryptsetup luksDump /dev/sda6
LUKS header information for /dev/sda6

Version:       	1
Cipher name:   	aes
Cipher mode:   	cbc-essiv:sha256
Hash spec:     	sha1
Payload offset:	1032
MK bits:       	128
MK digest:     	7b cf 6f 6a 64 96 0b b1 a2 ec 08 fc 0d 7f f7 bf c6 e5 3a 12 
MK salt:       	34 65 93 10 b6 8c dd 82 d8 1a 86 3b 36 2d a6 bf 
               	57 cc 2a d4 91 9c f3 28 c7 a7 c9 10 99 96 af a0 
MK iterations: 	10
UUID:          	33069df1-680d-4c28-b5ad-8bc9f14331cc

Key Slot 0: ENABLED
	Iterations:         	343972
	Salt:               	ff c1 6a 44 46 33 b2 ef 13 93 0c 17 c5 32 fe a2 
	                      	8e 24 06 29 a6 41 d9 67 64 54 2e be 87 c4 da 7c 
	Key material offset:	8
	AF stripes:            	4000
Key Slot 1: ENABLED
	Iterations:         	350728
	Salt:               	bc 0f ef 9d 24 3b 44 af 27 c6 3d 27 de 91 6b 55 
	                      	92 72 d3 04 3d 4b c6 4d c9 d9 1a 0c 05 86 05 17 
	Key material offset:	136
	AF stripes:            	4000
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED

2.5 - Suppression d'une clé

  cryptsetup luksDelKey /dev/sda6

2.6 - Fermer la partition cryptée

# cryptsetup luksClose stock

2.7 - Formater la partition

Ici on va formatter notre partition en ext3 :

# mkfs.ext3 /dev/mapper/stock

2.8 - Monter la partition cryptée

# mount -t ext3 /dev/mapper/stock /mnt/stock/

2.9 - Automatiser le montage

Editer le fichier /etc/crypttab ainsi :

# <target name>	<source device>		<key file>	<options>
stock 		/dev/sda6 		none 		luks,checkargs=ext2

Editer /etc/fstab :

/dev/mapper/stock       /mnt/stock      ext3    defaults        0       2

Au prochain démarrage, un mot de passe sera demandé pour monter la partition cryptée.

Vous êtes : 38.107.191.88 Dernière modification : 10/01/09 11:13 Propriétaire : Fritz Modifié par : Fritz

Commentaires

Afficher les commentaires
Il n'y a aucun commentaire sur cette page