Outils pour utilisateurs

Outils du site


issue67:tutoriel_-_ordinateur_anti-vol

Partie 1

In our modern society, computers become tools hosting a lot of private information. Losing these data or displaying these data to the public could have a big impact for the owner. In this article we will see how to: 1. Prevent the computer from booting on the secured system without a startup usb key The first barrier will be to prevent the PC from booting when it is not in the hands of its owner. To achieve this goal, we will “split” the hardware into two pieces. When these two pieces are joined, the computer can be used (and boot); if not, the computer will not start. As many people have to purchase Windows with a laptop, we will see how to give access to this OS when the key is not present. This could be useful if you want to lend your PC to a friend to give her access to the Internet. 2. Prevent the data from unwanted access If a person can access my disk, he should still not have access to the data. The file system and swap contain or can contain personal data. We will see how to encrypt the data at the level of the partition, and keep our data safe.

Dans notre société moderne, les ordinateurs deviennent des outils qui hébergent beaucoup d'informations privées. Perdre ces données ou les afficher au public pourraient constituer un préjudice important pour le propriétaire.

Dans cet article nous allons voir comment :

1. Empêcher l'ordinateur de démarrer sur le système sécurisé sans une clé de démarrage USB. La première barrière sera d'empêcher le PC de démarrer quand il n'est pas dans les mains de son propriétaire. Pour atteindre cet objectif, nous allons « diviser » le matériel en deux morceaux. Lorsque ces deux éléments sont réunis, l'ordinateur peut être utilisé (et démarrer) ; sinon l'ordinateur ne démarrera pas. Comme beaucoup de gens doivent acheter Windows avec leur ordinateur portable, nous allons voir comment donner accès à ce système d'exploitation lorsque la clé USB n'est pas présente. Cela peut être utile si vous voulez prêter votre PC à un ami pour lui donner accès à l'Internet.

2. Protéger les données contre tout accès non désiré. Si une personne peut accéder à mon disque, elle ne devrait toujours pas pouvoir accéder aux données. Le système de fichiers et le swap contiennent ou peuvent contenir des données personnelles. Nous allons voir comment crypter les données au niveau de la partition et garder nos données sécurisées.

3. Prevent data loss To prevent data loss, doing regular backup is something mandatory, but, if the backup storage is located in the same building as the computer, it may be robbed/destroyed as well. To prevent data loss, we need to externalize the data. The cloud is a good solution for such an externalization. It could be done in real time, and doesn't require any discipline from the end user. To ensure the privacy of the data in such cases, we will also encrypt the data before synchronizing it to the cloud. The data in the cloud is a mirror of the current data in the computer. 4. Use the created usb key as a toolbox by adding live distributions With the usb key in our hands, we will see how to add an additional live distributions that could be useful for troubleshooting or rescue.

3. Prévenir la perte de données. Pour éviter toute perte de données, faire des sauvegardes régulières est obligatoire, mais, si l'on stocke la sauvegarde dans le même bâtiment que l'ordinateur, elle peut également être volée ou détruite. Pour éviter toute perte de données, nous devons externaliser leur stockage. Le nuage est une bonne solution pour une telle externalisation. Cela pourrait être fait en temps réel et ne nécessite pas de discipline de la part de l'utilisateur final. Pour garantir la confidentialité des données dans de tels cas, nous allons également les crypter avant de les synchroniser dans le nuage. Les données dans le nuage sont un miroir des données actuelles dans l'ordinateur.

4. Utiliser la clé USB créée comme une boîte à outils en ajoutant des distributions live. Avec la clé USB, nous verrons comment ajouter des distributions live supplémentaires qui pourraient être utiles pour le dépannage ou le secours.

Installation To implement the procedure described below, you will need the following items: • A target computer (with or without an existing OS running) • Two blank CD-ROMs – to burn Ubuntu installation media • One USB key (min > 1GB, recommended > 4GB) • A computer with an operating system running (that could be the target) Preparation Download ubuntu-12.04.1-desktop-i386.iso from http://releases.ubuntu.com/precise/ and burn it to a CD-ROM. Plug in the usb key, and boot from the Ubuntu 12.04.1 desktop CD-ROM freshly burnt. In the welcome screen, select Try Ubuntu. Once the live system has booted, start gparted to prepare the usb key.

Installation

Pour mettre en œuvre la procédure décrite ci-dessous, vous aurez besoin des éléments suivants : • Un ordinateur cible (avec ou sans système d'exploitation en fonctionnement). • Deux CD-ROM vierges pour graver le support d'installation Ubuntu. • Une clé USB (min > 1 Go, recommandé > 4 Go). • Un ordinateur avec un système d'exploitation en exécution (qui pourrait être la cible)

Préparation

Téléchargez ubuntu-12.04.1-desktop-i386.iso à partir de http://releases.ubuntu.com/precise/ et gravez-le sur un CD-ROM.

Branchez la clé USB et démarrez à partir du CD-ROM d'Ubuntu 12.04.1 pour ordinateur de bureau fraîchement gravé.

Dans l'écran d'accueil, sélectionnez Try Ubuntu [Ndt : Essayer Ubuntu].

Une fois que le système « Live » a démarré, lancez gparted pour préparer la clé USB.

Select the usb key (/dev/sdb), and create a FAT32 partition preceded by a free space of 128MB. This space will be used later by the secured operating system. If your computer doesn't have an operating system installed, skip the next step of this chapter and continue with the following section. If you purchased Microsoft Windows with the laptop, we will keep it in the machine and available (in case you would like to lend your PC to your friends). First perform a backup of windows using the tools provided by your manufacturer… you may need or will have to restore Windows once the partition resizing is done. Resize the existing windows partition to leave space for the real operating system. • Boot on Ubuntu 12.04.1 desktop • Start GParted • Select the disk of the computer (/dev/sda) • Resize the windows partition to 50GB, it should be enough for all occasions when you need to use this OS • Remove unneeded partitions – to create free space that will be used to install Linux

Sélectionnez la clé USB (/dev/sdb) et créez une partition FAT32 précédée d'un espace libre de 128 Mo. Cet espace sera utilisé plus tard par le système d'exploitation sécurisé.

Si votre ordinateur ne dispose pas d'un système d'exploitation installé, sautez l'étape suivante de ce chapitre et passez à la section suivante.

Si vous avez acheté Microsoft Windows avec l'ordinateur portable, nous allons le laisser disponible dans la machine (au cas où vous souhaiteriez prêter votre PC à vos amis). D'abord, effectuez une sauvegarde de Windows en utilisant les outils fournis par votre fabricant… Vous pourriez avoir besoin de ou devrez restaurer Windows une fois le redimensionnement des partitions fait. Redimensionnez la partition existante de Windows pour laisser de l'espace pour le vrai système d'exploitation. • Démarrez sur Ubuntu 12.04.1 pour ordinateur de bureau. • Lancez gparted. • Choisissez le disque de l'ordinateur (/dev/sda). • Redimensionnez la partition Windows à 50 Go, ce qui devrait être suffisant pour toutes les occasions où vous aurez besoin d'utiliser ce système d'exploitation. • Supprimez les partitions inutiles : pour libérer de l'espace qui sera utilisé pour installer Linux.

Installation During the installation, we will configure the Operating System to encrypt the data stored in the disk. This encryption will ensure the security of the data. The longer the encryption key, the better the protection, but this also lengthens the time to encrypt and decrypt. In this article, we choose the shortest proposed length for the key: AES 128-bit should be fast and secure enough. A key of 128-bits give about 3,4 x 10^38 possibilities. To understand how secure 128-bit keys are, you may read the analogy by Jon Callas at: http://www.interesting-people.org/archives/interesting-people/200607/msg00058.html “Imagine a computer that is the size of a grain of sand that can test keys against some encrypted data. Also imagine that it can test a key in the amount of time it takes light to cross it. Then consider a cluster of these computers, so many that if you covered the earth with them, they would cover the whole planet to the height of 1 meter. The cluster of computers would crack a 128-bit key on average in 1,000 years.” Even if you don't believe that the NSA has another planet devoted to key cracking, you still may want to use a longer key. If a weakness in your chosen crypto-module is found, it may limit the keyspace that needs to be tested, and you will then have an effectively shorter key. Using a 256-bit key will keep your data secure much longer if that should happen.

Installation

Au cours de l'installation, nous allons configurer le système d'exploitation pour crypter les données stockées sur le disque. Ce cryptage assurera la sécurité des données. Plus la clé de cryptage est longue, meilleure est la protection, mais cela allonge également le temps nécessaire pour chiffrer et déchiffrer. Dans cet article, nous avons choisi la longueur la plus courte proposée pour la clé : AES 128-bit devrait être assez rapide et sécurisé. Une clé de 128 bits donne environ 3,4×10^38 possibilités.

Pour comprendre à quel point les clés de 128 bits sont sécurisées, vous pouvez lire l'analogie par Jon Callas ici : http://www.interesting-people.org/archives/interesting-people/200607/msg00058.html

« Imaginez un ordinateur qui a la taille d'un grain de sable qui peut tester les clés de certaines données chiffrées. Imaginez aussi qu'il puisse tester une clé dans la quantité de temps qu'il faut à la lumière pour le traverser. Ensuite, envisagez une grappe de ces ordinateurs, tellement grande que si vous en recouvriez la terre, ils recouvriraient la planète entière sur une hauteur de 1 mètre. La grappe d'ordinateurs craquerait une clé de 128 bits en moyenne en 1 000 ans. »

Même si vous ne croyez pas que la NSA a une autre planète consacrée au craquage des clés, vous voudrez peut-être utiliser une clé plus longue. Si une faiblesse dans le module de cryptage que vous avez choisi est trouvée, elle pourrait réduire la partie de la clé qui doit être testée et vous auriez alors une clé en réalité plus courte. Utiliser une clé de 256 bits vous permettra de garder vos données sécurisées beaucoup plus longtemps si cela devait arriver.

Download Ubuntu and burn it on the second CD-ROM. Boot on the freshly burnt CD-ROM. Select the language and Install Ubuntu. Follow these instructions to install the system: • Select the language to be used during the installation process: English • Select your location, configure locales, configure the keyboard • Define hostname, user and password • Do not chose to encrypt the home directory. We will encrypt all the partition. • Set clock and timezone • To Partition disks, select Manual Creating the /boot partition unencrypted • Select the freespace on sdb and press enter • Select Create a new partition

Téléchargez Ubuntu et gravez-le sur le deuxième CD-ROM.

Démarrez sur le CD-ROM fraîchement gravé. Sélectionnez la langue et installez Ubuntu.

Suivez ces instructions pour installer le système : • Sélectionnez la langue à utiliser pendant le processus d'installation : Français. • Sélectionnez votre emplacement, configurez les paramètres régionaux, configurez le clavier. • Donnez un nom d'hôte, d'utilisateur et un mot de passe. • Ne choisissez pas de crypter le répertoire home. Nous allons crypter la partition entière. • Réglez l'horloge et le fuseau horaire. • Pour partitionner les disques, choisissez Manuel.

Création de la partition /boot en clair [Ndt : non chiffrée] : • Cliquez sur l'espace libre de sdb et appuyez sur Entrée. • Cliquez sur Créer une nouvelle partition.

Define the size: keep the proposed size • Type of the new partition: Primary • Use As: Ext2 file system • Mount point: /boot • Bootable flag: on • Select Done setting up the partition Create a Logical partition • Select the free space on sda and press enter • Select Create a new partition • Define the size: 128M Type of the new partition: Primary • Location for the new partition: Beginning • Use as: do not use • Select Done setting up the partition

Définir la taille : gardez la taille proposée. • Type de la nouvelle partition : primaire. • Utilisation : système de fichiers Ext2. • Point de montage : /boot. • Indicateur d'amorçage : ON. • Cliquez sur Terminer [Ndt : Done] pour créer la partition.

Créer une partition logique : • Cliquez sur l'espace libre de sda et appuyez sur Entrée. • Cliquez sur Créer une nouvelle partition. • Donnez la taille : 128 Mo. • Type de la nouvelle partition : primaire. • Emplacement de la nouvelle partition : Beginning [Ndt : Début]. • Utilisation : ne pas utiliser. • Cliquez sur Terminer pour créer la partition.

Create a Logical partition • Select the free space on sda and press enter • Select Create a new partition • Define the size: keep the proposed size – which should be the maximum space available • Type of the new partition: Logical • Use as: do not use • Select Done setting up the partition Encrypt partition •Select Configure encrypted volumes •Write the change to disk and configure encrypted volumes: Yes • Select Create Encrypted volumes • Select: [*] /dev/sda5 • Key size: 128 •Done setting up the partition • Keep current partition layout and configure encrypted volume: Yes • Select Finish • Enter a passphrase twice

Créer une autre partition logique : • Cliquez sur l'espace libre de sda et appuyez sur Entrée. • Cliquez sur Créer une nouvelle partition. • Définir la taille : conserver la taille proposée, elle devrait être égale à l'espace maximum disponible. • Type de la nouvelle partition : logique. • Utilisation : ne pas utiliser. • Cliquez sur Terminer pour créer la partition.

Crypter la partition : • Cliquez sur Configurer des volumes chiffrés. • Écrire les changements sur le disque et configurer les volumes chiffrés : Oui. • Cliquez sur Créer des volumes chiffrés. • Sélectionner : [*] /dev/sda5. • Taille de la clé : 128. • Paramétrage de la partition terminé. • Garder la disposition actuelle des partitions et configurer le volume chiffré : Oui. • Cliquez sur Terminer. • Entrez une phrase de passe deux fois.

Create LVM group and volumes • Select Configuring the Logical Volume Manager • Write change to disk and configure LVM : Yes • Select Create volume group • Volume group name: VolGroup • Device for new volume group: [*] /dev/mapper/sda5_crypt • Keep current partition layout and configure LVM: Yes • Select Create logical volume • Volume group: VolGroup • Logical volume name: LV_slash • logical volume size: 50GB • Select Create logical volume • Volume group: VolGroup • Logical volume name: LV_swap • logical volume size: 2GB • Select Create logical volume • Volume group: VolGroup • Logical volume name: LV_home • Logical volume size: keep the proposed size • Select Finish

Créer le groupe et les volumes LVM : • Cliquez sur Configuration du gestionnaire de volumes logiques. • Écrire les changements sur le disque et configurer LVM : Oui. • Cliquez sur Créer un groupe de volumes. • Nom du groupe de volumes : VolGroup. • Disque pour le nouveau groupe de volumes : [*] /dev/mapper/sda5_crypt. • Garder la disposition actuelle des partitions et configurer LVM : Oui. • Cliquez sur Créer un volume logique. • Groupe de volumes : VolGroup. • Nom du volume logique : LV_slash. • Taille du volume logique : 50 Go. • Cliquez sur Créer un volume logique. • Groupe de volumes : VolGroup. • Nom du volume logique : LV_swap. • Taille du volume logique : 2 Go. • Cliquez sur Créer un volume logique. • Groupe de volumes : VolGroup. • Nom du volume logique : LV_home. • Taille du volume logique : garder la taille proposée. • Cliquez sur Terminer.

Configure the mounting points of LVM volumes • Select LV_home –> #1 • Use as : Ext4 journaling file system • Mount point: /home • Options: [*] noatime (–> we don't wish to record the last time the file has been read) • Select Done setting up the partition • Select LV_slash –> #1 • Use as : Ext4 journaling file system • Mount point: / • Options: [*] noatime • Select Done setting up the partition • Select LV_swap –> #1 • Use as : swap area • Select Done setting up the partition Finish partitioning and write changes to disk • Write changes to disks •Install GRUB on /dev/sdb (the key will then be required to boot on the secured system) •Set the system clock to UTC: Yes •Complete the installation Congratulations, you have now a system where your data is encrypted and needs an external usb key to start. As we didn't touch the mbr of the hdd, the previous operating system should continue to start as it did previously. It is now required to explicitly boot with the usb key to access the secured area. When doing so, you will see the boot screen asking the password required to decrypt the disk. We will see in the next chapter how to make our secured computer as easy to use as an unencrypted and unsecured computer, and we will configure it to ensure the sustainability of our data.

Configurer les points de montage des volumes LVM : • Sélectionnez LV_home –> #1. • Utilisation : système de fichiers journalisé Ext4. • Point de montage : /home. • Options : [*] noatime (–> nous ne voulons pas enregistrer la dernière fois que le fichier a été lu). • Cliquez sur Terminer le paramétrage de la partition. • Sélectionnez LV_slash –> #1. • Utilisation : système de fichiers journalisé Ext4. • Point de montage : /. • Options : [*] noatime. • Cliquez sur Terminer le paramétrage de la partition. • Sélectionnez LV_swap –> #1. • Utilisation : zone de swap. • Cliquez sur Terminer le paramétrage de la partition.

Terminer le partitionnement et sauver les modifications sur le disque : • Écrire les changements sur les disques. • Installez GRUB sur /dev/sdb (la clé USB sera alors nécessaire pour démarrer sur le système sécurisé). • Régler l'horloge système en UTC : Oui. • Terminez l'installation.

Félicitations, vous avez maintenant un système où vos données sont cryptées et qui a besoin d'une clé USB externe pour démarrer. Comme nous n'avons pas touché au MBR [Ndt : Master Boot Record] du disque dur, le système d'exploitation précédent devrait continuer à démarrer comme il le faisait auparavant. Il est maintenant obligatoire de démarrer explicitement avec la clé USB pour accéder à la zone sécurisée. Ce faisant, vous verrez l'écran de démarrage demander le mot de passe requis pour déchiffrer le disque.

Nous verrons dans le chapitre suivant comment rendre notre ordinateur sécurisé aussi facilement utilisable qu'un ordinateur non chiffré et non sécurisé et nous allons le configurer pour assurer la pérennité de nos données.

Configuration In this section we will see how to customize the system to improve its usability and to protect our data from loss. Warning: Unless specified, the commands below must be executed as root. Using a label for the USB key will allow us to duplicate this key and ensure that the system will recognize it as the booting device. Define the label for /dev/sdb2 as BOOT (/dev/sdb2 is the /boot partition) e2label /dev/sdb2 BOOT Update /etc/fstab to use label instead of uuid replace UUID=(…) by LABEL=BOOT

Configuration

Dans cette section, nous allons voir comment personnaliser le système afin d'améliorer son utilisabilité et de protéger nos données pour éviter leur perte.

Avertissement : Sauf indication contraire, les commandes ci-dessous doivent être exécutées en tant que root.

L'utilisation d'une étiquette pour la clé USB va nous permettre de la reproduire et de nous assurer que le système va la reconnaître comme étant le périphérique de démarrage.

Définissez l'étiquette de /dev/sdb2 à BOOT (/dev/sdb2 est la partition /boot)

e2label /dev/sdb2 BOOT

Mettez à jour le fichier /etc/fstab pour utiliser l'étiquette au lieu de l'UUID

remplacez UUID=(…) par LABEL=BOOT

Edit /etc/default/grub, uncomment to not use uuid in grub, and regenerate grub.cfg: uncomment GRUB_DISABLE_LINUX_UUID=true Insert the blue text (shown below) into the file /usr/lib/grub/grub-mkconfig_lib to configure grub to use label (if available in a volume) Upgrade grub with the following command: update-grub We will now configure the system to decrypt the partition based on a file stored in the startup key. The computer will then recognize the startup key and decrypt the partition without asking for a password anymore. Create a keyfile in /boot dd if=/dev/urandom of=/boot/keyfile bs=512 count=4 chmod 444 /boot/keyfile

Éditer le fichier /etc/default/grub, dé-commenter les lignes adéquates pour ne pas utiliser les UUID dans grub et régénérer grub.cfg :

Dé-commentez la ligne GRUB_DISABLE_LINUX_UUID=true

Insérez le texte en bleu (ci-dessous) dans le fichier /usr/lib/grub/grub-mkconfig_lib pour configurer grub pour qu'il utilise l'étiquette (si disponible dans un volume)

Mettez grub à jour avec la commande suivante :

update-grub

Nous allons maintenant configurer le système pour déchiffrer la partition basée sur un fichier stocké dans la clé USB de démarrage. L'ordinateur reconnaîtra alors la clé USB de démarrage et déchiffrera la partition sans jamais plus demander de mot de passe.

Créez un fichier de clés dans /boot :

dd if=/dev/urandom of=/boot/keyfile bs=512 count=4

chmod 444 /boot/keyfile

Add the new key into it as a valid key to decrypt the disk: cryptsetup luksAddKey /dev/sda5 keyfile Note: The contents of the file is important, not the filename. Modify /etc/crypttab to use the boot key. Replace: sdb5_crypt UUID=(…) none luks with sdb5_crypt UUID=(…) /dev/disk/by-label/BOOT:/keyfile luks,keyscript=/lib/cryptsetup/scripts/passdev Finally, update the initramfs with: update-initramfs -uv

Ajoutez la nouvelle clé dans ce fichier comme étant une clé valide pour déchiffrer le disque :

cryptsetup luksAddKey /dev/sda5 keyfile

Remarque : Le contenu du fichier est important, pas le nom du fichier.

Modifiez le fichier /etc/crypttab afin d'utiliser la clé USB de démarrage. Remplacez :

sdb5_crypt UUID=(…) none luks

par

sdb5_crypt UUID=(…) /dev/disk/by-label/BOOT:/keyfile luks,keyscript=/lib/cryptsetup/scripts/passdev

Enfin, mettez à jour initramfs avec :

update-initramfs -uv

To remove auto decryption and reactivate passphrase only, modify /etc/crypttab by adding the boot key and remove the line added. The file should then look something like this sdb5_crypt UUID=(…) none luks Finally, update the initramfs: update-initramfs -uv Booting from the main disk instead of startup key Some BIOS don't really like to boot from an external usb drive. In such a situation, we will create a screen displayed at boot that will allow the user to select which operating system to startup. We will use BURG which has a nice-looking graphical interface. This solution will modify the MBR of the HDD, so then you have to pay particular attention to the action proposed here.

Pour supprimer le décryptage automatique et réactiver la phrase de passe uniquement, modifiez le fichier /etc/crypttab en ajoutant la clé USB de démarrage et supprimez la ligne ajoutée. Le fichier devrait alors ressembler à ceci :

sdb5_crypt UUID=(…) none luks

Puis, mettez à jour initramfs :

update-initramfs -uv

Démarrer depuis le disque principal au lieu de la clé USB de démarrage.

Certains BIOS n'aiment pas vraiment démarrer à partir d'un disque externe USB. Dans une telle situation, nous allons créer un écran affiché au démarrage qui permettra à l'utilisateur de sélectionner le système d'exploitation à démarrer. Nous allons utiliser BURG, qui dispose d'une belle interface graphique. Cette solution va modifier le MBR du disque dur, donc vous devez porter une attention particulière à l'action proposée ici.

First create symlinks vmlinuz and initrd to the latest kernel and initrd image: cd /boot ln -s vmlinuz-… vmlinuz ln -s initrd.img-… initrd.img Warning: After every kernel upgrade, you will have to update these links pointing to the latest kernel Mount the /boot partition of HDD: umount /boot mount /dev/sda2 /boot

D'abord, créez des liens symboliques vmlinuz et initrd vers le dernier noyau et l'image initrd :

cd /boot

ln -s vmlinuz-… vmlinuz

ln -s initrd.img-… initrd.img

Attention : Après chaque mise à jour du noyau, vous devrez mettre à jour ces liens pour qu'ils pointent vers le noyau le plus récent.

Montez la partition /boot du disque dur :

umount /boot

mount /dev/sda2 /boot

Install BURG on the system: apt-get install python-software-properties add-apt-repository ppa:n-muench/burg apt-get update apt-get install burg Configure BURG to run from the internal HDD: • Accept default parameters • Select /dev/sda Edit /etc/burg/30_osprober and append the keyword exit at the beginning of the file. Edit /etc/burg.d/10_linux and append the keyword exit before the last while.

Installez BURG sur le système :

apt-get install python-software-properties

add-apt-repository ppa:n-muench/burg

apt-get update

apt-get install burg

Configurez BURG pour qu'il se lance à partir du disque dur interne : • Acceptez les paramètres par défaut. • Sélectionnez /dev/sda.

Éditez le fichier /etc/burg/30_osprober et ajoutez le mot clé « exit » au début du fichier.

Éditez le fichier /etc/burg.d/10_linux et ajoutez le mot clé « exit » avant le dernier « while ».

Update custom menu to boot on Linux or Windows: menuentry “Linux” –class ubuntu { insmod ext2 set root=(hd1,2) linux /vmlinuz quiet splash initrd /initrd.img } menuentry “Windows” –class windows { set root=(hd0,1) chainloader +1 } Edit /etc/default/burg and uncomment: GRUB_DISABLE_LINUX_RECOVERY=“true”

Modifiez le menu personnalisé pour pourvoir démarrer soit sur Linux soit sur Windows :

menuentry “Linux” –class ubuntu {

insmod ext2
set root=(hd1,2)
linux /vmlinuz quiet splash
initrd /initrd.img

} menuentry “Windows” –class windows {

set root=(hd0,1)
chainloader +1

}

Éditez le fichier /etc/default/burg et dé-commentez la ligne suivante :

GRUB_DISABLE_LINUX_RECOVERY=“true”

Apply the configuration • update-burg Here is the screen that will be displayed at startup: Note: Note that this boot screen doesn't propose recovery mode. The full startup menu is still available on the usb key. You should select to boot on the usb key, and hold shift to access to the following menu. Note: This screenshot (right) is showing additional boot options. Ref below to see how to install live OS into the usb key.

Appliquez la configuration : • update-burg

Voici l'écran qui s'affichera au démarrage :

Remarque : Notez que cet écran de démarrage ne propose pas de mode de récupération. Le menu de démarrage complet est toujours disponible sur la clé USB. Vous devrez alors choisir de démarrer sur la clé USB et maintenir la touche MAJ pour accéder au menu suivant.

Remarque : Cette capture d'écran (à droite) montre les options de démarrage supplémentaires. Voir les références ci-dessous pour savoir comment installer un système d'exploitation « Live » sur la clé USB.

Partie 2

Create a startup key from a working system

If you have a system running, it is easy to recreate a USB key with the following procedure:

Mount the new key in /media/usb… Note: The key should be prepared with gparted as described above, and have the partition formatted as ext2.

mount /dev/sdc2 /media/usb

Copy the content of the original key to the new startup key:

cp -a /boot/* /media/usb

Label the new key to be a boot key:

e2label /dev/sdc2 BOOT

Install grub2 to the new disk:

grub-install –force –no-floppy –boot-directory=/media/usb –root-directory=/ /dev/sdc

Note: Each time the kernel is updated, the second key will also have to be updated using this procedure.

Backup the startup key and store it in a safe location

The usb key you just created is now the only way you have to start your computer. It is mandatory to have a backup of it and to be able to recreate it.

Cleanup unused space of /boot partition:

dd if=/dev/zero of=/boot/todelete

rm /boot/todelete

Umount /boot partition:

umount /dev/sdb2

Backup the mbr of the usb key:

dd if=/dev/sdb of=startup.mbr bs=512 count=1

Backup the boot partition:

dd if=/dev/sdb2 of=startup.sdb2

Compress the backup:

tar cvjf startup.bkp.tar.bz2 startup.mbr startup.sdb2

Store the file startup.bkp.tar.bz2 into a safe area.

Warning: This to perform an update of the startup key image after every kernel update.

Restore the startup key to another key

The following action should be performed on the computer freshly installed, or from a live version of the OS created from UnetBootIn, or start from the startup key when installation is completed.

Plug the new target usb key and identify its device. Let's assume it is /dev/sdc. Enter these commands:

dd if=startup.mbr of=/dev/sdc

mkfs.vfat /dev/sdc1

dd if=startup.sdb2 of=/dev/sdc2

fsck -y /dev/sdc2

mount /dev/sdc2 /media/usb

grub-install –force –no-floppy –boot-directory=/media/usb –root-directory=/ /dev/sdc

This command could be a little bit long. Executing the following command will let dd write a status of its progress:

kill -USR1 $(pidof dd)

Store data in a remote location to ensure its availability

Our goal is to store data in a place that will ensure its availability even if the hardware is lost. The easiest solution is to use the cloud services provided by one of the following companies:

Online storages services:

For Windows only, some additional space can be used to store non-confidential data:

Offline backup service:

Online notebook:

This solution is not intended to replace real backup/restore solutions, but has the advantages of being cheap and easy to setup.

Ensure the confidentiality of data stored into the cloud

The cloud is a private storage area provided by an external company. This description may not sound correct, because it is mixture of private and external. So, if we consider that this external area is not a fully private place, we will have to add another layer of encryption to secure our data in the cloud. For this, we will use encfs, and we will configure pam to automatically unlock the directory during the login process.

Install encfs and fuse-utils using the following command as root:

apt-get install encfs fuse-utils

sh -c “echo fuse » /etc/modules”

modprobe fuse

adduser $USER fuse

Configure the encryption of sensitive data into in Ubuntu One

Execute the following commands as standard user:

sudo apt-get install libpam-mount libpam-encfs

LC_ALL=C encfs /home/$USER/Ubuntu\ One/.encrypted /home/$USER/encrypted/

Let encfs create the directories. Select the pre-configured paranoia mode (p), or just press enter to have normal protection.

Enter the passphrase twice (it should be the same as for the account if you want to use pam_mount).

It is possible to automatically decrypt the encfs directory using pam_mount. This will work only if the passphrase of the user account is the same as the passphrase of the encfs directory.

Edit the file /etc/security/pam_mount.conf.xml look for the line <!– Volume definitions –>. Append the following lines just after by replacing «user» with your login

<volume user=“«user»” fstype=“fuse” path=“encfs#/home/«user»/Ubuntu One/.encrypted” mountpoint=“/home/«user»/encrypted” />

Passphrase management

The LUKS encryption system can manage up to eight passphrases (in this article, we already used two). Adding a password can be done with the following command:

cryptsetup luksAddKey /dev/sda5

To delete a passphrase:

cryptsetup luksKillSlot /dev/sda5 <the slot number to be deleted>

To change a passphrase, you need to add the new key, then to kill the slot of the key to be replaced.

Encfs has only one passphrase. The passphrase can be changed with the following command:

encfsctl passwd ~/Ubuntu\ One/.encrypted/

Add live OS into the usb key

On the following section, we will assume that the FAT32 partition of the startup key is mounted in /media/usb. If this is not yet the case, execute the following command to do it:

mkdir /media/usb

mount /dev/sdb1 /media/usb

Add ubuntu desktop on the usb stick. Create the directory /media/usb/iso

mkdir /media/usb/iso

Download ubuntu-12.04.1-desktop-i386.iso from http://releases.ubuntu.com/precise/ and copy it to /media/usb/iso.

Create the file /etc/grub.d/42_custom with the text shown above.

Upgrade grub with the following command

update-grub

Add Unbuntu Alternate CD on the usb stick. Download Ubuntu and copy it in /media/usb/iso. Create the file /etc/grub.d/43_custom with the content shown below:

Upgrade grub with the following command

update-grub

Add System Rescue CD on the usb stick. Download and copy it in /media/usb/iso. Create the file /etc/grub.d/44_custom with the content shown top right.

Upgrade grub with the following command:

update-grub

Online security

You are using Linux, this is a first good step for online security. If you intend to use your computer directly connected to the Internet, you should at least start the firewall by executing the following command:

ufw enable

Remove the key after startup

Warning: In this section, it is proposed to modify the authentication process. An error could block the authentication of your computer. If you do so, start your computer in recovery mode and delete the modification you previously did. Be aware that the option to remove the key is available only in the graphical interface. We do consider that if you start a console, you can as well mount the /boot partition manually.

To not compromise the security of your PC, you need to carry the usb key with you all the time even if the PC is still running and locked.

To make this easy we will configure the computer to automatically mount and umount the key on different occasions:

Umount the key: • At startup to let you unplug the key and go before login • When the computer is locked – to let you unplug the key when you need to leave your PC • When you close your session

Mount the usb key: • When you open a session • When the session is unlocked

Umount key after boot

Add the following as the first active line of the file /etc/rc.local

umount /boot

This will umount the usb key after boot.

Traduction

Créer une clé de démarrage à partir d'un système en fonctionnement.

Si vous avez un système en cours d'exécution, il est facile de recréer une clé USB comme suit :

Montez la nouvelle clé dans /media/usb. Remarque : La clé doit être préparée avec gparted comme décrit ci-dessus et la partition doit être formatée en ext2.

mount /dev/sdc2 /media/usb

Copiez le contenu de la clé originale vers la nouvelle clé de démarrage :

cp -a /boot/*/media/usb

Étiquetez la nouvelle clé pour qu'elle soit amorçable :

e2label /dev/sdc2 BOOT

Installez grub2 sur le nouveau disque :

grub-install –force –no-floppy –boot-directory=/media/usb –root-directory=/ /dev/sdc

Remarque : Chaque fois que le noyau sera mis à jour, la deuxième clé devra également être mise à jour en utilisant cette procédure.

Sauvegardez la clé de démarrage et stockez-la dans un endroit sûr.

La clé USB que vous venez de créer est maintenant le seul moyen que vous avez pour démarrer votre ordinateur. Il est obligatoire de l'avoir sauvegardée et d'être en mesure de la recréer.

Nettoyez l'espace inutilisé de la partition /boot :

dd if=/dev/zero of =/boot/todelete

rm /boot/todelete

Démontez la partition /boot :

umount /dev/sdb2

Sauvegardez le MBR de la clé USB :

dd if=/dev/sdb of=startup.mbr bs=512 count=1

Sauvegardez la partition de démarrage :

dd if=/dev/sdb2 of=startup.sdb2

Compressez la sauvegarde :

tar cvjf startup.bkp.tar.bz2 startup.mbr startup.sdb2

Rangez le fichier startup.bkp.tar.bz2 dans un endroit sûr.

Avertissement : Faites cela pour effectuer une mise à jour de l'image de la clé de démarrage après chaque mise à jour du noyau.

Restaurer la clé de démarrage sur une autre clé.

Les actions suivantes doivent être exécutées sur l'ordinateur fraîchement installé, ou à partir d'une version « live » de l'OS créée à partir de UnetBootIn, ou à partir de la clé de démarrage lorsque l'installation est terminée.

Branchez la nouvelle clé USB cible et identifiez son périphérique. Supposons que c'est /dev/sdc. Entrez les commandes suivantes :

dd if=startup.mbr of=/dev/sdc

mkfs.vfat /dev/sdc1

dd if=startup.sdb2 of=/dev/sdc2

fsck -y /dev/sdc2

mount /dev/sdc2 /media/usb

grub-install –force –no-floppy –boot-directory=/media/usb –root-directory=/ / dev/sdc

Cette commande peut être un peu longue. L'exécution de la commande suivante permettra à dd d'écrire un état de sa progression :

kill -USR1 $(pidof dd)

Stocker les données dans un emplacement distant pour assurer leur disponibilité.

Notre objectif est de stocker les données dans un endroit qui assurera leur disponibilité même si le matériel est défectueux. La solution la plus simple est d'utiliser les services dans le nuage fournis par l'une des sociétés suivantes :

Services de stockage en ligne :

5 Go jusqu'à 20 Go gratuits - https://one.ubuntu.com/

5 Go gratuits - https://www.wuala.com/

2 Go gratuits - https://www.dropbox.com/

2 Go gratuits - https://www.spideroak.com/

5 Go gratuits - https://drive.google.com/ –> avec grive : https://github.com/Grive/grive

Pour Windows uniquement, un peu d'espace supplémentaire peut être utilisé pour stocker des données non confidentielles :

5 Go gratuits - https://www.sugarsync.com/

7 Go gratuits - https://skydrive.live.com/

Service de sauvegarde hors ligne :

25 Go gratuits - https://www.hubic.me/

Bloc-note en ligne :

60 Mo/mois gratuits - https://www.evernote.com/

Cette solution n'est pas destinée à remplacer des solutions de sauvegarde/restauration réelles mais offre l'avantage d'être peu chère et facile à mettre en place.

Assurer la confidentialité des données stockées dans le nuage.

Le nuage est une zone de stockage privée fournie par une société externe. Cette description peut ne pas sembler correcte, car c'est un mélange de privé et d'externe. Donc, si l'on considère que cette zone externe n'est pas un endroit totalement privé, nous devrons ajouter une autre couche de cryptage pour sécuriser nos données dans le nuage. Pour cela, nous allons utiliser encfs et nous allons configurer pam pour déverrouiller automatiquement le répertoire pendant le processus de connexion.

Installez encfs et fuse-utils à l'aide des commandes suivantes en tant que root :

apt-get install encfs fuse-utils

sh -c “echo fuse » /etc/modules”

modprobe fuse

adduser $USER fuse

Configurer le cryptage des données sensibles dans Ubuntu One.

Exécutez les commandes suivantes en tant qu'utilisateur standard :

sudo apt-get install libpam-mount libpam-encfs

LC_ALL=C encfs /home/$USER/Ubuntu\ One/.encrypted /home/$USER/encrypted/

Laissez encfs créer les répertoires. Sélectionnez le mode paranoïa pré-configuré (p) ou appuyez simplement sur Entrée pour avoir une protection normale.

Entrez le mot de passe deux fois (il devrait être le même que pour le compte si vous souhaitez utiliser pam_mount).

Il est possible de décrypter automatiquement le répertoire encfs utilisant pam_mount. Cela fonctionnera uniquement si le mot de passe du compte utilisateur est le même que le mot de passe du répertoire encfs.

Modifiez le fichier/etc/security/pam_mount.conf.xml : cherchez la ligne <!– Volume définitions –>. Ajoutez les lignes suivantes juste après, en remplaçant « user » par votre nom d'utilisateur

<volume user=“«user»” fstype=“fuse” path=“encfs#/home/«user»/Ubuntu One/.encrypted” mountpoint=“/home/«user»/encrypted” />

Gestion des phrases de passe

Le système de chiffrement LUKS peut gérer jusqu'à huit phrases de passe (dans cet article, nous en avons déjà utilisé deux). Vous pouvez ajouter un mot de passe avec la commande suivante :

cryptsetup luksAddKey /dev/sda5

Pour supprimer une phrase de passe :

cryptsetup luksKillSlot /dev/sda5 <le numéro d'emplacement à supprimer>

Pour changer un mot de passe, vous devez ajouter la nouvelle clé, puis tuer l'emplacement de la clé à remplacer. Encfs n'a qu'un seul mot de passe. Le mot de passe peut être changé avec la commande suivante :

encfsctl passwd ~/Ubuntu\ One/.encrypted/

Ajouter des OS « live » sur la clé USB

Dans la section suivante, nous supposons que la partition FAT32 de la clé de démarrage est montée dans /media/usb. Si ce n'est pas encore le cas, exécutez la commande suivante pour le faire :

mkdir /media/usb

mount /dev/sdb1 /media/usb

Ajouter Ubuntu pour ordinateur de bureau sur la clé USB. Créez le répertoire /media/usb/iso :

mkdir /media/usb/iso

Téléchargez ubuntu-12.04.1-desktop-i386.iso à partir de http://releases.ubuntu.com/precise/ et copiez-le dans /media/usb/iso.

Créez le fichier /etc/grub.d/42_custom avec le texte ci-dessus.

Mettez à jour grub avec la commande suivante :

update-grub

Ajoutez Ubuntu Alternate CD sur la clé USB. Télécharger Ubuntu et copiez-le dans /media/usb/iso. Créez le fichier /etc/grub.d/43_custom avec le contenu ci-dessous :

Mettez à jour grub avec la commande suivante :

update-grub

Ajoutez System Rescue CD sur la clé USB. Téléchargez-le et copiez-le dans/media/usb/iso. Créez le fichier/etc/grub.d/44_custom avec le contenu affiché en haut à droite.

Mettez à jour grub avec la commande suivante :

update-grub

Sécurité en ligne

Vous utilisez Linux, c'est une bonne première étape pour la sécurité en ligne. Si vous avez l'intention d'utiliser votre ordinateur directement connecté à Internet, vous devriez au moins démarrer le pare-feu en exécutant la commande suivante :

ufw enable

Retirez la clé après le démarrage.

Attention : Dans cette section, le processus d'authentification sera modifié. Une erreur pourrait bloquer l'authentification de votre ordinateur. Si vous en faites une, démarrez votre ordinateur en mode sans échec et supprimez la modification que vous avez faite précédemment. Soyez conscient que la possibilité de supprimer la clé est uniquement disponible dans l'interface graphique. Nous considérons que si vous lancez une console, vous pouvez aussi monter la partition /boot manuellement.

Pour ne pas compromettre la sécurité de votre PC, la clé USB doit toujours être dans votre possession, même si le PC est toujours en fonctionnement et verrouillé.

Pour faciliter ce processus, nous allons configurer l'ordinateur pour monter et démonter automatiquement la clé à différentes occasions :

Démonter la clé : • Au démarrage pour vous permettre de débrancher la clé et partir avant la connexion. • Lorsque l'ordinateur est verrouillé, pour vous permettre de débrancher la clé lorsque vous avez besoin de quitter votre PC. • Lorsque vous fermez votre session.

Monter la clé USB : • Lorsque vous ouvrez une session. • Lorsque la session est déverrouillée.

Démonter la clé après le démarrage.

Ajoutez la ligne suivante comme première ligne active du fichier /etc/rc.local :

umount /boot

Cela démontera la clé USB après le démarrage.

Partie 3

Now, we need to authorize a standard user to mount and umount the /boot partition which is in the startup key. To do so, it is required to update the /boot description in the file /etc/fstab and append the option ‘users’ as an option. After modification, the line should look like this:

LABEL=BOOT /boot ext2 noatime,users 0 2

To automatically mount and umount the key when the session is open or close, we will use the capabilities given by PAM. libpam-script will allow us to execute a script when the user opens or closes a session.

Install libpam-script with the following command:

apt-get install libpam-script

/usr/share/libpam-script/pam_script_ses_open is executed when the session is open, and will mount the partition /boot. Create this script with the following content:

#!/bin/bash if "$PAM_USER" = "lightdm" || ( mount | grep /boot > /dev/null 2>&1 ); then

  exit 0

fi if ( mount /boot > /dev/null 2>&1 ); then

  /usr/bin/aplay /usr/share/sounds/purple/receive.wav > /dev/null 2>&1

fi exit 0

This script mounts the /boot partition, and plays a sound letting you know that the key has been successfully reconnected.

Change permissions to make it executable:

chmod 755 /usr/share/libpam-script/pam_script_ses_open

/usr/share/libpam-script/pam_script_ses_close is executed when the session is closed, and will dismount the partition /boot. Create this script with the following content:

#!/bin/bash if "$PAM_USER" = "lightdm"; then

  	exit 0

fi device=$(mount | grep /boot | cut -c -8) if ( umount /boot > /dev/null 2>&1 ); then

umount $device* > /dev/null 2>&1
/usr/bin/aplay /usr/share/sounds/purple/send.wav > /dev/null 2>&1

fi exit 0

This script umounts the /boot partition and all the partitions of the usb key, and then plays a sound letting you know that you can remove the usb key safely.

Change permissions to make it executable:

chmod 755 /usr/share/libpam-script/pam_script_ses_close

We need now to add pam_script to the session management. Modify the file /etc/pam.d/lightdm and append the pam_script line below just after the line @include common-account:

@include common-account

session optional pam_script.so

We will now create a script managing the screen-saver. The script below is applicable to xscreensaver which is the default screensaver of xubuntu. If your screensaver is different, you can replace it by xcreenserver, or (more difficult), you can update the script below.

Create the file /usr/local/bin/startup_key_manager.sh with the following content:

#!/bin/bash /usr/bin/xscreensaver-command -watch | while read line; do

  if [ x"$(echo "$line" | grep 'LOCK')" != x ] ; then
/usr/share/libpam-script/pam_script_ses_close
  fi
  if [ x"$(echo "$line" | grep 'UNBLANK')" != x ] ; then
 	/usr/share/libpam-script/pam_script_ses_open
  fi

done

Change the permissions to make it executable:

chmod 755 /usr/local/bin/startup_key_manager.sh

This script will monitor the screensaver and manage the /boot partition of the key accordingly.

This script should be added to start automatically when the session is open. As a normal user, create the script ~/.config/autostart/startupKeyManager.desktop with the following content:

[Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=startupKeyManager Comment=startup key manager Exec=/usr/local/bin/startup_key_manager.sh StartupNotify=false Terminal=false Hidden=false

The script will be activated when you will start another session.

Warning: When you are updating the kernel, be sure the session will stay open and the screen server stays deactivated during the upgrade.

Two-factor authentication

Warning: In this section, it is proposed to modify the authentication process for graphical as well as console login. An error could block the authentication of your computer. If you do so, start your computer in recovery mode, and delete the modification you previously did.

We have now a system which is secured and easy to use, but we can improve the security a little bit by adding a two-factor authentication requiring the USB key to be plugged and the password to be correct before opening the session. With this two-factor authentication, you will be sure that, in the event that somebody knows your password, she will not be able to unlock your session when you are at the coffee corner with the USB key in your pocket.

To activate the two factor authentication, we will use the pam module previously installed: pam-script.

The logic would be to use pam_usb, but this approach is inconvenient: It requires an action on every USB key you have, and makes key replication more complex. So, we will authenticate the usb key based on the keyfile present in it using pam_script.

Create the script /usr/share/libpam-script/pam_script_ses_auth dedicated to authenticate the usb key with the following content:

#!/bin/bash mount /boot result=1; if ( sha1sum -c –status /usr/share/libpam-script/keycheck ); then

  result=0

fi umount /boot exit $result

Make it executable:

chmod 755 /usr/share/libpam-script/pam_script_auth

The sha1sum is used to validate the key; the keycheck file is created with the following commands:

sha1sum /boot/keyfile > /usr/share/libpam-script/keycheck

chmod 444 /usr/share/libpam-script/keycheck

We need now to add pam_script into the system authentication process just after the authentication by password. Modify the file /etc/pam.d/common-auth and add pam_script just after pam_deny as follow:

auth requisite pam_deny.so

auth required pam_script.so

Troubleshooting

In some circumstances you may need to access to the data of the encrypted partition without booting the computer. Here are some methods to do so.

Boot in recovery mode

Boot from the usb stick and select recovery mode. Select root, Drop to root shell prompt. Mount / with a read write access and mount /boot using the following commands

mount -oremount,rw /

mount /dev/sdb2 /boot

Note: As you are using your startup key to boot your PC, you are identified to be the owner of the machine if you used a keyfile; you will be granted root access without any password. Without the key, such a startup is impossible and you will have to follow the instruction of the next section to access your data.

Manual access to the partition

To access to the encrypted partition, boot on a live Operating System and follow the procedure below to mount and umount the disk.

Mount encrypted partition

modprobe dm-crypt

cryptsetup luksOpen /dev/sdb5 crypt

(Enter your passphrase)

vgscan –mknodes

vgchange -ay

mkdir /mnt/crypt

mount /dev/VolGroup/LV_slash /mnt/crypt

Umount partition

umount /mnt/crypt

vgchange -an

cryptsetup luksClose crypt

To gain access to the encrypted partition from (initramfs):

Mount encrypted partition

cryptsetup luksOpen /dev/sdb5 crypt

mkdir /mnt/crypt

mount /dev/VolGroup/LV_slash /mnt/crypt

Umount partition

umount /mnt/crypt

cryptsetup luksClose crypt

Reinstall the secure system and keep data in the home directory

In case of a major issue, you may have to reinstall your system from scratch. Boot on Ubuntu Alternate image • Enter the name of the computer • Enter the full name of the main user • Enter the username for the account • Choose a password and enter it twice • Do not select to encrypt home directory (We will reuse the encrypted partition already existing into the system) • Set clock timezone • Partition disks: Manual • Select: Configure encrypted volume • • Keep current partition layout and configure encrypted volumes: Yes • • Activate existing encrypted volume • • Enter the passphrase • • You will see the LVM volumes in the disk partition description • Define mounting point as described in the previous chapter (Format the partition / and /boot but do not format the partition /home) • Install the OS • Reboot

After this installation /boot and / have been recreated from scratch. It is then required to reapply the configuration described in the previous section. If you use a keyfile to unlock the secured partition, this file should be reinstalled in the /boot partition from the backup you did. If you previously saved the installed packages into a file installed-packages as described in the Security: section, it is possible to reinstall them with the following commands:

apt-get update

apt-get upgrade

dpkg –set-selections < installed-packages

apt-get -u dselect-upgrade

To go further and improve the security and data integrity

Additional action could improve the security of your computer. You can, for instance, remove Windows from your computer. In this case, your computer will not boot at all without the startup key, and will be unusable and without any evidence that it holds an encrypted partition. Then you can add a BIOS password to avoid booting from usb, and add a password to burg and grub to avoid startup command modification.

You can also use TrueCrypt with/without inner volume to secure confidential data.

To go even further, you can apply the recommendation from the NSA: http://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf

References

This article has been written based on information found in the Internet:

https://help.ubuntu.com/community/EncryptedFilesystemHowto

http://ubuntuforums.org/showthread.php?t=1549847

http://ubuntuforums.org/showthread.php?t=1369019

http://blog.stalkr.net/2012/05/usb-rescue-and-secure-boot-disk.html

http://askubuntu.com/questions/63594/mount-encrypted-volumes-from-command-line

http://ubunteros.tuxfamily.org/spip.php?article204

http://doc.ubuntu-fr.org/tutoriel/chiffrer_son_disque

http://doc.ubuntu-fr.org/cryptsetup

http://doc.ubuntu-fr.org/encfs

http://linuxconfig.org/linux-authentication-login-with-usb-device

http://artisan.karma-lab.net/petite-introduction-a-pam

http://www.psychocats.net/ubuntu/security

https://code.google.com/p/cryptsetup/

TRADUCTION

Il faut maintenant autoriser un utilisateur standard à monter et démonter la partition /boot qui est la clé de démarrage. Pour ce faire, il est nécessaire de mettre à jour la description de /boot dans le fichier /etc/fstab et d'ajouter l'option « utilisateurs ». Après modification, la ligne devrait ressembler à ceci :

LABEL=BOOT /boot ext2 noatime,users 0 2

Pour monter et démonter automatiquement la clé lorsque la session est ouverte ou fermée, nous allons utiliser les fonctionnalités fournies par le PAM. libpam-script va nous permettre d'exécuter un script lorsque l'utilisateur ouvre ou ferme une session.

Installez libpam-script avec la commande suivante :

apt-get install libpam-script

/usr/share/libpam-script/pam_script_ses_open est exécuté lorsque la session est ouverte et montera la partition /boot. Créez ce script avec le contenu suivant :

#!/bin/bash if "$PAM_USER" = "lightdm" || ( mount | grep /boot > /dev/null 2>&1 ); then

  exit 0

fi if ( mount /boot > /dev/null 2>&1 ); then

  /usr/bin/aplay /usr/share/sounds/purple/receive.wav > /dev/null 2>&1

fi exit 0

Ce script démonte la partition /boot et toutes les partitions de la clé USB, puis joue un son qui vous permet de savoir que vous pouvez retirer la clé USB en toute sécurité.

Modifiez les permissions pour le rendre exécutable :

chmod 755 /usr/share/libpam-script/pam_script_ses_open

/usr/share/libpam-script/pam_script_ses_close est exécutée lorsque la session est fermée et la partition /boot démontée. Créez ce script avec le contenu suivant :

#!/bin/bash if "$PAM_USER" = "lightdm"; then

  	exit 0

fi device=$(mount | grep /boot | cut -c -8) if ( umount /boot > /dev/null 2>&1 ); then

umount $device* > /dev/null 2>&1
/usr/bin/aplay /usr/share/sounds/purple/send.wav > /dev/null 2>&1

fi exit 0

Nous devons maintenant ajouter pam_script à la gestion de session. Modifiez le fichier /etc/pam.d/lightdm et ajoutez la ligne pam_script (ci-dessous) juste après la ligne @include common-account : @include common-account session optional pam_script.so

Nous allons maintenant créer un script de gestion de l'économiseur d'écran. Le script ci-dessous est applicable à xscreensaver qui est l'écran de veille par défaut de Xubuntu. Si votre écran est différent, vous pouvez le remplacer par xscreensaver, ou (plus difficile), vous pouvez mettre à jour le script ci-dessous.

Créez le fichier /usr/local/bin/startup_key_manager.sh avec le contenu suivant :

#!/bin/bash /usr/bin/xscreensaver-command -watch | while read line; do

if [ x"$(echo "$line" | grep 'LOCK')" != x ] ; then

/usr/share/libpam-script/pam_script_ses_close

fi
if [ x"$(echo "$line" | grep 'UNBLANK')" != x ] ; then

/usr/share/libpam-script/pam_script_ses_open

fi

done

Modifiez les permissions pour le rendre exécutable :

chmod 755 /usr/local/bin/startup_key_manager.sh

Ce script permet de surveiller l'écran et de gérer la partition /boot de la clé en conséquence.

Ce script doit être ajouté pour démarrer automatiquement lorsque la session est ouverte. En tant qu'utilisateur normal, créez le script ~/.config/autostart/startupKeyManager.desktop avec le contenu suivant :

[Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=startupKeyManager Comment=startup key manager Exec=/usr/local/bin/startup_key_manager.sh StartupNotify=false Terminal=false Hidden=false

Le script sera activé lorsque vous démarrerez une autre session.

Avertissement : Lorsque vous mettez à jour le noyau, assurez-vous que la session reste ouverte et que le serveur de l'écran reste désactivé pendant la mise à niveau.

Authentification à deux facteurs

Avertissement : Dans cette section, il est proposé de modifier le processus d'authentification pour le mode graphique ainsi que la connexion de la console. Une erreur pourrait bloquer l'authentification de votre ordinateur. Si vous en faites une, démarrez votre ordinateur en mode sans échec et supprimez la modification que vous avez faite.

Nous avons maintenant un système qui est sécurisé et facile à utiliser, mais nous pouvons améliorer la sécurité un peu en ajoutant une authentification à deux facteurs, nécessitant que la clé USB soit branchée et le mot de passe correct avant l'ouverture de la session. Avec cette authentification à deux facteurs, vous serez sûr que, dans le cas où quelqu'un connaît votre mot de passe, il ne sera pas en mesure de débloquer votre session lorsque vous êtes au coin café avec la clé USB dans votre poche.

Pour activer l'authentification à deux facteurs, nous allons utiliser le module pam déjà installé : pam-script.

La logique serait d'utiliser pam_usb, mais cette approche n'est pas pratique; Elle nécessite une action sur chaque clé USB que vous avez et rend la réplication de la clé plus complexe. Nous allons donc authentifier la clé USB sur la base du fichier de clé qu'il contient en utilisant pam_script.

Créez le script /usr/share/libpam-script/pam_script_ses_auth pour authentifier la clé USB avec le contenu suivant :

#!/bin/bash mount /boot result=1; if ( sha1sum -c –status /usr/share/libpam-script/keycheck ); then

result=0

fi unmount /boot exit $result

Rendez-le exécutable :

chmod 755 /usr/share/libpam-script/pam_script_auth

Le sha1sum est utilisé pour valider la clé et le fichier keycheck est créé avec les commandes suivantes :

sha1sum /boot/keyfile > /usr/share/libpam-script/keycheck

chmod 444 /usr/share/libpam-script/keycheck

Nous devons maintenant ajouter pam_script dans le processus d'authentification du système juste après l'authentification par mot de passe. Modifiez le fichier /etc/pam.d/common-auth et ajoutez pam_script juste après pam_deny comme suit :

auth requisite pam_deny.so

auth required pam_script.so

Dépannage

Dans certaines circonstances, il peut être nécessaire d'accéder aux données de la partition chiffrée sans avoir à démarrer l'ordinateur. Voici quelques méthodes pour le faire.

Démarrer en mode sans échec

Démarrez à partir de la clé USB et sélectionnez le mode sans échec. Sélectionnez root et l'invite de commande s'affichera. Monter / avec un accès en écriture/lecture et monter /boot en utilisant les commandes suivantes :

mount -oremount,rw /

mount /dev/sdb2 /boot

Remarque : Lorsque vous utilisez votre clé de démarrage pour démarrer votre PC, vous êtes identifié comme le propriétaire de la machine si vous avez utilisé un fichier de clé et vous allez bénéficier d'un accès root sans mot de passe. Sans la clé, un tel démarrage est impossible et vous devrez suivre les instructions de la section suivante pour accéder à vos données.

Accès manuel à la partition

Pour accéder à la partition chiffrée, démarrez sur un système d'exploitation en fonctionnement et suivez la procédure ci-dessous pour monter et démonter le disque.

Monter une partition chiffrée

modprobe dm-crypt

cryptsetup luksOpen / dev/sdb5 crypte

(Entrez votre phrase de passe.)

vgscan-mknodes

vgchange-ay

mkdir / mnt / crypt

mount / dev / volgroup / LV_slash / mnt / crypt

Démonter la partition

unmount /mnt/crypt

vgchange -an

cryptsetup luksClose crypt

Pour accéder à la partition cryptée à partir de (initramfs) :

Monter la partition chiffrée

cryptsetup luksOpen/dev/sdb5 crypt

mkdir/mnt/crypt

mount/dev/volgroup/LV_slash /mnt/crypt

Démonter la partition

unmount /mnt/crypt

cryptsetup luksClose crypt

Réinstaller le système sécurisé et conserver les données dans le répertoire home

En cas de problème majeur, vous pourriez avoir besoin de réinstaller votre système à partir de zéro. Démarrez sur ​​Ubuntu Alternate Image : • Entrez le nom de l'ordinateur. • Entrez le nom complet de l'utilisateur principal. • Entrez le nom d'utilisateur du compte. • Choisissez un mot de passe et saisissez-le deux fois. • Ne pas choisir de crypter le répertoire personnel (nous allons utiliser la partition chiffrée déjà existante). • Réglage du fuseau horaire. • Partitionnement du disque dur : Manuel. • Sélectionnez : Configurer le volume chiffré. • Gardez la disposition actuelle des partitions et configurez les volumes chiffrés : Oui. • Activez le volume chiffré existant. • Entrez la phrase de passe. • Vous verrez les volumes LVM dans la description du partionnement du disque. • Définissez le point de montage comme décrit dans le chapitre précédent (formater les partitions / et /boot, mais ne pas formater la partition /home). • Installez le système d'exploitation. • Redémarrez.

Après cette installation /boot et / ont été recréés à partir de zéro. Il est alors nécessaire de ré-appliquer la configuration décrite dans la section précédente. Si vous utilisez un fichier de clé pour déverrouiller la partition sécurisée, ce fichier doit être réinstallé dans la partition /boot à partir de la sauvegarde que vous avez faite. Si vous avez enregistré précédemment les paquets installés dans un fichier installed-packages comme décrit dans la section Sécurité, il est possible de les réinstaller avec les commandes suivantes :

apt-get update

apt-get upgrade

dpkg –set-selections < installed-packages

apt-get -u dselect-upgrade

Pour aller plus loin et améliorer la sécurité et l'intégrité des données

Des mesures supplémentaires pourraient améliorer la sécurité de votre ordinateur. Vous pouvez, par exemple, supprimer Windows. Dans ce cas, votre ordinateur ne démarrera pas du tout sans la clé de démarrage et sera inutilisable et la partition chiffrée n'apparaîtra même pas. Ensuite, vous pouvez ajouter un mot de passe BIOS pour éviter de démarrer à partir de l'USB et ajouter un mot de passe burg et grub pour éviter toute modification de commande de démarrage.

Vous pouvez également utiliser TrueCrypt avec/sans volume intérieur pour sécuriser les données confidentielles.

Pour aller encore plus loin, vous pouvez appliquer la recommandation de la NSA : http://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf

Références

Cet article a été rédigé à partir d'informations trouvées sur Internet :

https://help.ubuntu.com/community/EncryptedFilesystemHowto

http://ubuntuforums.org/showthread.php?t=1549847

http://ubuntuforums.org/showthread.php?t=1369019

http://blog.stalkr.net/2012/05/usb-rescue-and-secure-boot-disk.html

http://askubuntu.com/questions/63594/mount-encrypted-volumes-from-command-line

http://ubunteros.tuxfamily.org/spip.php?article204

http://doc.ubuntu-fr.org/tutoriel/chiffrer_son_disque

http://doc.ubuntu-fr.org/cryptsetup

http://doc.ubuntu-fr.org/encfs

http://linuxconfig.org/linux-authentication-login-with-usb-device

http://artisan.karma-lab.net/petite-introduction-a-pam

http://www.psychocats.net/ubuntu/security

https://code.google.com/p/cryptsetup/

issue67/tutoriel_-_ordinateur_anti-vol.txt · Dernière modification : 2013/02/08 13:52 de auntiee