Меню сайта
Категории каталога
Шифрование дискового раздела во FreeBSD при помощи GEOM-ELI [2008] Часть 2
Работает он примерно так: # ./crypto.sh ##################################################### # GEOM-ELI SCRIPT # ##################################################### [?]Enter 'y' to mount or 'n' to umount GEOM-ELI partition: [y/n] y [?]Enter the encrypted partition: ar0s1g [?]Enter the mounting point: /crypto [!]Your partition is ar0s1g [!]Mounting point is /crypto [!]Trying to mount USB Flash drive on /mnt ... [?]Enter the USB Flash device (da0s1 da1s1): [da0s1] [!]USB FLASH Device /dev/da0s1 successfully mounted on /mnt Enter passphrase: [!]Key for GEOM-ELI provider attached to /dev/ar0s1g [!]GEOM-ELI encrypted provider mounted to /crypto Geom name: ar0s1g.eli EncryptionAlgorithm: Blowfish-CBC KeyLength: 384 AuthenticationAlgorithm: HMAC/SHA512 Crypto: software UsedKey: 0 Flags: AUTH Providers: 1. Name: ar0s1g.eli Mediasize: 83886075904 (78G) Sectorsize: 4096 Mode: r1w1e1 Consumers: 1. Name: ar0s1g Mediasize: 104857600000 (98G) Sectorsize: 512 Mode: r1w1e1 И так: # ./crypto.sh ##################################################### # GEOM-ELI SCRIPT # ##################################################### [?]Enter 'y' to mount or 'n' to umount GEOM-ELI partition: [y/n] n [?]Deattach the GEOM-ELI provider ? [y/n] y [!]Found GEOM-ELI provider at /dev/ar0s1g.eli [!]GEOM-ELI provider deattached Вообщем, мне так удобней. Да, и еще. Желательно не забыть из /etc/fstab убрать строку устройства ar0s1g, а то система не загрузится # sed -ie '/ar0s1g/d' /etc/fstab Ну вот в принципе и все. Связываем главный ключ с провайдером, ключевая фраза и сгенерированный файл на флешке служат дешифрацией главного ключа для создания нового GEOM провайдера. В каталоге /dev должен появиться файл /dev/ar0s1g.eli: # geli attach -k /mnt/ar0s1g.key /dev/ar0s1g Enter passphrase: # ls /dev | grep eli ar0s1g.eli Далее достаточно продолжительная процедура создания файловой системы (у меня ушло на это около 4-часов): # dd if=/dev/random of=/dev/ar0s1g.eli bs=1m dd: /dev/ar0s1g.eli: short write on character device dd: /dev/ar0s1g.eli: end of device 80000+0 records in 79999+1 records out 83886075904 bytes transferred in 14054.799294 secs (5968500 bytes/sec) # newfs /dev/ar0s1g.eli /dev/ar0s1g.eli: 80000.0MB (163839992 sectors) block size 16384, fragment size 4096 using 238 cylinder groups of 336.98MB, 21567 blks, 21568 inodes. super-block backups (for fsck -b #) at: 160, 690304, 1380448, 2070592, 2760736, 3450880, 4141024, 4831168, 5521312, 6211456, 6901600, 7591744, 8281888, 8972032, 9662176, 10352320, 11042464, 11732608, 12422752, 13112896, 13803040, 14493184, 15183328, 15873472, 16563616, 17253760, 17943904, 18634048, 19324192, 20014336, 20704480, 21394624, 22084768, 22774912, 23465056, 24155200, 24845344, 25535488, 26225632, 26915776, 27605920, 28296064, #-----SKIPPED-----# Создадим произвольный файл длиной 512 байт на нашей новой ФС: # dd if=/dev/urandom of=/crypto/testfile bs=512 count=1 1+0 records in 1+0 records out 512 bytes transferred in 0.000068 secs (7535030 bytes/sec) # ls -lh /crypto total 2 drwxrwxr-x 2 root operator 512B 4 дек 07:18 .snap -rw-r--r-- 1 root wheel 512B 4 дек 09:52 testfile Теперь отмонтируем /crypto, отсоединим провайдера /dev/ar0s1g.eli и выведем список файлов директории. Тестового файла там нету. # umount /crypto # geli detach /dev/ar0s1g.eli # ls -lh /crypto total 0 Попробуем смонтировать устройство /dev/ar0s1g - неверный супер-блок: # mount /dev/ar0s1g /crypto mount: /dev/ar0s1g on /crypto: incorrect super block Попробуем с неверным ключем или фразой попытаться подключить провайдера - как видим, ничего не получается: # dd if=/dev/random of=/root/wrong.key bs=64 count=1 1+0 records in 1+0 records out 64 bytes transferred in 0.000058 secs (1104673 bytes/sec) # geli attach -k /root/wrong.key /dev/ar0s1g Enter passphrase: Wrong key for ar0s1g. # geli attach -k /mnt/ar0s1g.key /dev/ar0s1g Enter passphrase: Wrong key for ar0s1g. Для своего удобства, накатал несложный скрипт на $BASH для монтирования-демонтирования шифрованной файловой системы (при условии, что она единственная на сервере). особо его не тестил, но у меня работает вроде все: #!/usr/local/bin/bash printf " ##################################################### # GEOM-ELI SCRIPT # ##################################################### \n"; printf "[?]Enter 'y' to mount or 'n' to umount GEOM-ELI partition: [y/n] "; read answer case "${answer}" in y|Y) printf "[?]Enter the encrypted partition: "; read partition; if [ ! -c /dev/${partition} ] then printf "[!]There is no such device - ${partition}"; exit 1 fi printf "[?]Enter the mounting point: "; read mount; if [ ! -d ${mount} ] then printf "[!]There is no such directory - ${mount}\n"; exit 1 fi printf "[!]Your partition is ${partition} [!]Mounting point is ${mount} [!]Trying to mount USB Flash drive on /mnt ...\n"; declare -a flash=( $(ls /dev | egrep 'da\ws\w') ) if [ ${#flash[@]} -ge 1 ] then for usbd in ${flash} do umount -f /dev/${usbd} 2&>1 done printf "[?]Enter the USB Flash device (${flash[*]:0}): [${flash[0]}]"; read usbdevice; if [ -z ${usbdevice} ] then usbdevice=${flash[0]} if [ ! -d /mnt ] then mkdir /mnt fi if mount_msdosfs -o ro /dev/${usbdevice} /mnt then printf "[!]USB FLASH Device /dev/${usbdevice} successfully mounted on /mnt\n"; else printf "[!]Can't mount USB Flash Device\n"; exit 1; fi fi fi findgeli=$(df -H | grep eli | /usr/bin/awk '{print $1}') if [ ${findgeli} ] then printf "[!]You have already the GEOM-ELI encrypted provider at ${findgeli}\n"; exit 1; else if geli attach -k /mnt/${partition}.key /dev/${partition} &> /dev/null then printf "[!]Key for GEOM-ELI provider attached to /dev/${partition}\n"; mount /dev/${partition}.eli ${mount} &> /dev/null printf "[!]GEOM-ELI encrypted provider mounted to ${mount}\n\n"; geli list umount -f /dev/${usbd} 2&>1 else printf "[!]Can't attach the key /mnt/${partition}.key\n"; exit 1; fi fi ;; n|N) printf "[?]Deattach the GEOM-ELI provider ? [y/n]" read answer case "${answer}" in y|Y) device=$(df -H | grep .eli | /usr/bin/awk '{print $1}') mount=$(df -H | grep .eli | /usr/bin/awk '{print $6}') if [ ${device} ] then printf "[!]Found GEOM-ELI provider at ${device}\n"; umount -f ${mount} geli detach ${device} printf "[!]GEOM-ELI provider deattached\n"; exit 0; else printf "[!]GEOM-ELI provider not found\n"; exit 1 fi ;; n|N) printf "[!]Exiting\n"; exit 0 ;; *) printf "[!]Enter 'y' or 'n'\n"; exit 1; ;; esac ;; *) printf "[!]Enter 'y' or 'n'\n"; exit 1; ;; esac Работает он примерно так: # ./crypto.sh ##################################################### # GEOM-ELI SCRIPT # ##################################################### [?]Enter 'y' to mount or 'n' to umount GEOM-ELI partition: [y/n] y [?]Enter the encrypted partition: ar0s1g [?]Enter the mounting point: /crypto [!]Your partition is ar0s1g [!]Mounting point is /crypto [!]Trying to mount USB Flash drive on /mnt ... [?]Enter the USB Flash device (da0s1 da1s1): [da0s1] [!]USB FLASH Device /dev/da0s1 successfully mounted on /mnt Enter passphrase: [!]Key for GEOM-ELI provider attached to /dev/ar0s1g [!]GEOM-ELI encrypted provider mounted to /crypto Geom name: ar0s1g.eli EncryptionAlgorithm: Blowfish-CBC KeyLength: 384 AuthenticationAlgorithm: HMAC/SHA512 Crypto: software UsedKey: 0 Flags: AUTH Providers: 1. Name: ar0s1g.eli Mediasize: 83886075904 (78G) Sectorsize: 4096 Mode: r1w1e1 Consumers: 1. Name: ar0s1g Mediasize: 104857600000 (98G) Sectorsize: 512 Mode: r1w1e1 И так: # ./crypto.sh ##################################################### # GEOM-ELI SCRIPT # ##################################################### [?]Enter 'y' to mount or 'n' to umount GEOM-ELI partition: [y/n] n [?]Deattach the GEOM-ELI provider ? [y/n] y [!]Found GEOM-ELI provider at /dev/ar0s1g.eli [!]GEOM-ELI provider deattached Вообщем, мне так удобней. Да, и еще. Желательно не забыть из /etc/fstab убрать строку устройства ar0s1g, а то система не загрузится # sed -ie '/ar0s1g/d' /etc/fstab Ну вот в принципе и все. Источник: http://www.lissyara.su/?id=1566
Категория: Установка и настройка | Добавил: oleg (19.02.2008) | Автор: netcat
Просмотров: 894 | Рейтинг: 0.0 /0 |
- Оценить -
Отлично
Хорошо
Неплохо
Плохо
Ужасно
Добавлять комментарии могут только зарегистрированные пользователи.
[
Регистрация |
Вход ]
Форма входа
Друзья сайта