ããŒã3ïŒYubikey 4ãšLUKS
ã¯ããã«
ãã®èšäºã§ã¯ãYubikey 4ããŒã䜿çšããŠæå·åãããLUKSããŒãã£ã·ã§ã³ãããŠã³ããã2èŠçŽ èªèšŒã®å®è£ ã«ã€ããŠèª¬æããŸãã
Yubikey 4ããŒã䜿çšããŠ2èŠçŽ èªèšŒãå®è£ ããæå·åãããLUKSããŒãã£ã·ã§ã³ãããŠã³ãããããã»ã¹ã¯ã3ã€ã®éšåã«åããããšãã§ããŸãã
1. LUKSã»ã¯ã·ã§ã³ã®æºåã
2.ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§Yubikey 4ããŒã䜿çšããæºåãããŸãã
3.äºèŠçŽ èªèšŒã«Yubikey 4ããŒãçŽæ¥äœ¿çšããŸãã
åææ¡ä»¶ïŒ
- Linux Mint 18 Sarah 64-ããã
- ãŠãããŒ4
LUKSã»ã¯ã·ã§ã³ã®æºå
æ¢åã®LUKSã»ã¯ã·ã§ã³ã®äºååæãå¿ èŠã§ãã
Yubikey 4ããŒã䜿çšãã2èŠçŽ èªèšŒã䜿çšããã«ã¯ãLUKSã»ã¯ã·ã§ã³ã«1ã€ã®ç©ºãã¹ããããå¿ èŠã§ãã ãããã£ãŠã空ããŠããã¹ãããã®æ°ãšã¹ããããç¥ãå¿ èŠããããŸãã
ããã«ãã¡ã€ã³ããŒãçŽå€±ïŒèª€ã£ãŠæžãæãïŒããå Žåã«åããŠãè¿œå ã®ïŒããã¯ã¢ããïŒããŒãå ¥åãããšäŸ¿å©ã§ãã è¿œå ã®ã»ãã¥ãªãã£å¯ŸçãšããŠãMasterKeyãã³ããäœæã§ããŸãã
/ dev / sdb1ã§ã¯ãªããå®éã®ã·ã¹ãã ã§ã¯å¥ã®ããã€ã¹ã䜿çšã§ããããšã«æ³šæããããšãéèŠã§ãã ãã®èšäºã®ã³ãã³ãã¯ã説æã®ããã«æäŸãããŠããŸãã ããšãã°ãã·ã¹ãã ã§ã¯ãããã€ã¹/ dev / sdb5ã«ãªããŸãã
8ã€ã®LUKSããŒã¹ããã
LUKSã¯ãæå·åããã1ã€ã®ããŒãã£ã·ã§ã³ã«8ã€ã®ã¹ãããã䜿çšããŸããåããŒãã£ã·ã§ã³ã«ã¯åå¥ã®ããŒãä¿åã§ããŸãã 8ã€ã®ããŒã®ããããã䜿çšããŠãããŒãã£ã·ã§ã³ã埩å·åã§ããŸãã 1ã€ã®ããŒã®ã¿ã䜿çšããããšãã8ã€ãã¹ãŠãå²ãåœãŠãããšãã§ããŸãã
ãã¹ãŠã®ã¹ãããã衚瀺ããã«ã¯ã cryptsetupã³ãã³ãã䜿çšããå¿ èŠããããŸãã
# cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: DISABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED
ãã®äŸã§ã¯ïŒ
- / dev / sdb1-LUKSã»ã¯ã·ã§ã³ã
- ããŒã¹ãããã¯çªå·0ããå§ãŸããŸãããããã£ãŠãã¹ããã0ã7ã䜿çšã§ããŸãã
- ENABLED-ã¹ãããã«ã¯LUKSã»ã¯ã·ã§ã³ã«å²ãåœãŠãããããŒãå«ãŸããŸãã
- ããŒãä¿åããããã«2ã€ã®ã¹ããããæå®ãããŠããŸãã
æ°ããããŒãè¿œå ãã
æå·åãããLUKSã»ã¯ã·ã§ã³ã®æ°ããããŒïŒãã¹ãã¬ãŒãºïŒãè¿œå ããã«ã¯ãluksAddKeyã³ãã³ãã䜿çšããŸãã
# cryptsetup luksAddKey /dev/sdb1 Enter any passphrase: Enter new passphrase for key slot: Verify passphrase:
ãã®äŸã§ã¯ïŒ
- / dev / sdb1-æå·åãããããŒãã£ã·ã§ã³
- ãã¹ãã¬ãŒãºãå ¥åããŸãã-æ¢åã®ããŒãå ¥åããŸã
- ããŒã¹ãããã®æ°ãããã¹ãã¬ãŒãºãå ¥åããŸãã-æ°ããããŒãå ¥åããŸã
- ãã¹ãã¬ãŒãºã®ç¢ºèªïŒ-æ°ããããŒã®å ¥åãç¹°ãè¿ããŸã
æ°ããããŒã¯ã次ã«äœ¿çšå¯èœãªã¹ãããã«è¿œå ãããŸãã ãã®å Žåãã¹ããã2ã«ãªããŸãã
# cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: ENABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED
æå®ãããã¹ãããã«æ°ããããŒãè¿œå ãã
æå®ãããã¹ãããã«ããŒãè¿œå ããã«ã¯ãã¹ãããçªå·ã§-Sãªãã·ã§ã³ã䜿çšããŸãã
# cryptsetup luksAddKey /dev/sdb1 -S 5 # cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: ENABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: <b>ENABLED</b> Key Slot 6: DISABLED Key Slot 7: DISABLED
æ¢åã®ããŒãåé€ãã
æ¢åã®ããŒãåé€ããã«ã¯ãluksRemoveKeyã³ãã³ãã䜿çšããŸãã
# cryptsetup luksRemoveKey /dev/sdb1 Enter LUKS passphrase to be deleted:
ããŒãåé€ããå Žåãã¹ãããçªå·ã¯äœ¿çšãããŸããããã¹ãã¬ãŒãº-ããŒïŒã¿ãŒã²ããã¹ãããã«å²ãåœãŠãããããŒïŒãå ¥åããå¿ èŠããããŸãã
# cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: ENABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED
ããŒã®åé€
ããŒãåé€ããã«ã¯ãluksKillSlotã³ãã³ãã䜿çšããŸãã ãã®ã³ãã³ãã¯ãã¿ãŒã²ããã¹ãããã®ããŒããªãããã®ã¹ãããããããŒãåé€ããã ãã®å Žåã«äœ¿çšãããŸãã
ã¹ãããçªå·2ããããŒãåé€ããŸãã å²ãåœãŠãããLUKSããŒãå ¥åããããæ±ããããŸãã
# cryptsetup luksKillSlot /dev/sdb1 2 Enter any remaining LUKS passphrase:
çµæïŒ
# cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: DISABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED
ãã¡ã€ã«ããæ°ããLUKSããŒãè¿œå ãã
ãã¡ã€ã«ããæ°ããããŒãè¿œå ããããšãã§ããŸãã
# cryptsetup luksAddKey /dev/sdb1 masterkeyfile Enter any passphrase:
ãã®äŸã§ã¯ïŒ
- masterkeyfileã«ã¯ãè¿œå ããæ°ããããŒãå«ãŸããŠããŸãã ãã€ããªïŒãã€ããªïŒãã¡ã€ã«ã§ããå¿ èŠããããŸãã
- ãã¹ãã¬ãŒãºã®å ¥åãæ±ããããããæå®ããã/ dev / sdb1ããŒãã£ã·ã§ã³ã®æ¢åã®ããŒã®ãããããå ¥åããå¿ èŠããããŸãã
çµæïŒ
# cryptsetup luksDump /dev/sdb1 | grep Slot Key Slot 0: ENABLED Key Slot 1: ENABLED Key Slot 2: ENABLED Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED
å¿ããããLUKSããŒããªã»ãããã-æ°ããããŒãã€ã³ã¹ããŒã«ãã
ãµãŒããŒããªããŒãããLUKSãã¹ã¯ãŒããå¿ããããã«æå·åãããLUKSããŒãã£ã·ã§ã³ãããŠã³ãã§ããªãå Žåããªãã·ã§ã³ã¯ãããŸããã ããŒã¿ã倱ãããŸãã å床ããŒãã£ã·ã§ã³ãæäœããå¿ èŠããããŸãïŒæå·åãå Žåã«ãã£ãŠã¯åããŒãã£ã·ã§ã³åããã¡ã€ã«ã·ã¹ãã ã®äœæãããŒã¿ã®å ¥åïŒã
ãã ããæå·åãããLUKSããŒãã£ã·ã§ã³ããŸã éããŠããå Žåãã·ã¹ãã ãåèµ·åããã«ããŸã ããŠã³ããããŠãããã®ããŒãã£ã·ã§ã³ã®LUKSãã¹ã¯ãŒããå¿ããŠããŸã£ãå Žåãæ°ããLUKSããŒãå²ãåœãŠãããšãã§ããŸãã
ãLUKSãã¹ã¯ãŒããå¿ãããã·ããªãªã§ã¯ã次ã®2ã€ã®æé ãå®è¡ã§ããŸãã
- LUKSã»ã¯ã·ã§ã³ããçŸåšã®æå·åããŒãæœåºããŸãã
- äºåã«å²ãåœãŠãããããŒã䜿çšããŠãæ°ããLUKSããŒãäœæããŸãã
ãã®äŸã§ã¯ãæå·åãããLUKSããŒãã£ã·ã§ã³ã§ãã/ home1ããŒãã£ã·ã§ã³ãããŠã³ããããŠããŸããããã®ãã¹ã¯ãŒãã¯äžæã§ãã
# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 127G 44G 76G 37% / /dev/mapper/home1 93G 188M 88G 1% /home1
ããªã¥ãŒã åã¯ãã/ dev / mapper /ãã®åŸã®ãdf -hãã³ãã³ãã®åºåã®æåã®åã«ãããŸãããã®äŸã§ã¯ãããªã¥ãŒã åã¯ãhome1ãã§ãã
次ã®ã³ãã³ãã¯ãã·ã¹ãã ã«ããŠã³ããããŠãããã¹ãŠã®ããŒãã£ã·ã§ã³ã®ãã¹ãŠã®æå·åããŒã®ãªã¹ãã衚瀺ããŸãã
# dmsetup table --showkeys home1: 0 197259264 crypt aes-cbc-essiv:sha256 607f482870c795a9b1e307ffbfc6643eaa219e9ef8c6773de02cd298c8fcda3c 0 8:17 4096
ãaes-cbc-essivïŒsha256ãã®åŸã®ãã£ãŒã«ãã¯ãæå·åããããã¹ã¯ãŒãã§ãã æå·åãããLUKSããŒãååŸãããã¡ã€ã«ã«ä¿åããŸãã
# vi existinglukskey.txt 607f482870c795a9b1e307ffbfc6643eaa219e9ef8c6773de02cd298c8fcda3c
ãããã£ãŠãåä¿¡ããããŒãããã¹ããã¡ã€ã«ãããã€ããªãã¡ã€ã«ã«å€æããŸãã ãããè¡ãã«ã¯ããxxdãã³ãã³ãã䜿çšããŸãã
# xxd -r -p existinglukskey.txt existinglukskey.bin
ãã®äŸã§ã¯ïŒ
- éå€æã®-rãªãã·ã§ã³ã ããã«ãããhexdumpããã€ããªã«å€æãããŸãã
- ãã¹ãã¹ã¯ãªãããåŠçãã-pãªãã·ã§ã³ã ããã§ã¯ãmanããã¥ã¢ã«ïŒpostscripté£ç¶hexdumpã¹ã¿ã€ã«ã§åºåããã¬ãŒã³hexdumpã¹ã¿ã€ã«ãšãåŒã°ããŸãïŒãé©åã«ç¿»èš³ããããšã¯å°é£ã§ãã
- existinglukskey.txtå ¥åãã¡ã€ã«ã
- æ¢åã®lukskey.binåºåãã¡ã€ã«ã ãã€ããªãã¡ã€ã«ã«æ¢åã®æå·åãããLUKSãã¹ã¯ãŒããå«ãŸããŸãã
æåŸã«ããã€ããªãã¡ã€ã«ã§éžæããæ¢åã®ããŒã䜿çšããŠãæ°ããLUKSããŒãè¿œå ããŸãã
# cryptsetup luksAddKey /dev/sdb1 --master-key-file <(cat existinglukskey.bin) Enter new passphrase for key slot: Verify passphrase:
ãã®äŸã§ã¯ïŒ
- --master-key-fileãã€ããªãã¡ã€ã«ãæå®ããŸãã å ¥åã®æ¢åã®lukskey.txtãã¡ã€ã«ã䜿çšããªãã§ãã ããã åºåã®æ¢åã®lukskey.binãã¡ã€ã«ã䜿çšããŸãã
- ã芧ã®ãšãããcryptsetup luksAddKeyã³ãã³ãã¯ããã€ããªãã¡ã€ã«ããååŸããããããæ¢åã®LUKSãã¹ã¯ãŒãã«ã€ããŠå°ããŸããã
- ãããŒã¹ãããã®æ°ãããã¹ãã¬ãŒãºãå ¥åããŠãã ããïŒããšããããã³ããã衚瀺ãããããæ°ããLUKSãã¹ã¯ãŒããå ¥åããŸãã ãããŠãä»åã¯å¿ããªãã§ãã ããã
LUKS MasterKeyããã³ããã
MasterKeyããã³ãããŠãå®å šãªå Žæã«ä¿ç®¡ããããšãã§ããŸãã MasterKeyãã³ãã䜿çšãããšãã ãã§ãLUKSã»ã¯ã·ã§ã³ã«ã¢ã¯ã»ã¹ã§ããããšã«æ³šæããŠãã ããã
# cryptsetup luksDump --dump-master-key /dev/sdb1 Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: LUKS header information for /dev/sdb1 Cipher name: aes Cipher mode: cbc-essiv:sha256 Payload offset: 4096 UUID: 146d639a-757c-4bcb-aee6-8fe815345104 MK bits: 256 MK dump: 60 7f 48 28 70 c7 95 a9 b1 e3 07 ff bf c6 64 3e aa 21 9e 9e f8 c6 77 3d e0 2c d2 98 c8 fc da 3c
ãããã£ãŠãäžèšã®æ¹æ³ã䜿çšããŠãããã«ã¢ã¯ã·ã§ã³ãå®è¡ããã«ã¯ä»¥äžãå®è¡ããå¿ èŠããããŸãã
- æå·åãããLUKSããŒãã£ã·ã§ã³ãæã€ããã€ã¹ãç¹å®ããŸãã
- ããŒãæžã蟌ãããã«ç©ºãã¹ãããã決å®ããŸãã
- å¿ èŠã«å¿ããŠãæ°ããããŒãè¿œå ããŸãïŒããã¯ã¢ããïŒã
ãœãŒã¹
翻蚳ã¯ãã®ãµã€ãã«åºã¥ããŠããŸã ã
cryptsetupãŠãŒãã£ãªãã£ã®æäœã«é¢ãã詳现ãªèª¬æã¯ããã®èšäºã®ç¯å²å€ã§ãã
ãåžæã®æ¹ã¯ãcryptsetupãŠãŒãã£ãªãã£ã®ã¢ããªã±ãŒã·ã§ã³ãšãªãã·ã§ã³ãç¬èªã«ç解ããããšãã§ããŸãã å§ããããã®ãªãœãŒã¹ã¯æ¬¡ã®ãšããã§ããwiki.archlinux.org ã gitlab.com ã
cryptsetupãŠãŒãã£ãªãã£ã®æäœã«é¢ãã詳现ãªèª¬æã¯ããã®èšäºã®ç¯å²å€ã§ãã
ãåžæã®æ¹ã¯ãcryptsetupãŠãŒãã£ãªãã£ã®ã¢ããªã±ãŒã·ã§ã³ãšãªãã·ã§ã³ãç¬èªã«ç解ããããšãã§ããŸãã å§ããããã®ãªãœãŒã¹ã¯æ¬¡ã®ãšããã§ããwiki.archlinux.org ã gitlab.com ã
ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã§Yubikey 4ããŒã䜿çšããæºå
Yubikey 4ããŒã䜿çšããã«ã¯ããœãããŠã§ã¢ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãUbuntuããŒãžã§ã³16.04以éã«åºã¥ãã·ã¹ãã ã§ã¯ã次ã®ã³ãã³ããå®è¡ãããŸãã
1. sudo apt-get install yubikey-luks
2. sudo apt-get install yubikey-personalization
3. Yubikey 4ããŒãUSBã¹ãããã«æ¿å ¥ããŠãã³ãã³ããå®è¡ããŸãã
ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible
Yubikeyã«ã¯2ã€ã®ã¹ãããããããŸãã ããã§ã¯ã¹ãããïŒ2ã䜿çšããããããã¹ãããïŒ1ã¯éåžžã®ãOTPãã¢ãŒãã§äœ¿çšã§ããŸãã
4. Yubikey 4ããŒãLUKSã¹ãããã«ããã€ã³ããããã«ã¯ããyubikey-luks-enrollãã³ãã³ãã䜿çšããŸãã å®è¡å¯èœãã¡ã€ã«ïŒã¹ã¯ãªããïŒã¯ã/ usr / bin / yubikey-luks-enrollã«ãããŸãã ãã®ã¹ã¯ãªããã¯ãLUKSããŒãã£ã·ã§ã³ãããã€ã¹/ dev / sda5äžã«ãããšæ³å®ããŠããŸãã ãããåœãŠã¯ãŸããªãå Žåã¯ãã¹ã¯ãªãããããŒã ãã£ã¬ã¯ããªã«ã³ããŒããŠãè¡ã調æŽããŸãã
DISK="/dev/sda5"
BIOSãšUEFIãæèŒããã·ã¹ãã ã§ã¯ãæå·åãããããŒãã£ã·ã§ã³ã«äœ¿çšãããããã€ã¹åã«éããããããšã«æ³šæããŠãã ããã BIOSã䜿çšããŠããŒãããã·ã¹ãã ã®å Žåãæå·åã®ããã©ã«ãã®ããªã¥ãŒã åã¯/ dev / sda5ã§ãã UEFIããŒããåããã·ã¹ãã ã®å Žåãæå·åãããããŒãã£ã·ã§ã³ã®ããã©ã«ãã®ããªã¥ãŒã åã¯/ dev / sda3ã§ãã
5.ã¹ã¯ãªããyubikey-luks-enrollã®ãã©ã¡ãŒã¿ãŒã調æŽããåŸãå®è¡ããŸãã ã¹ã¯ãªãããå®è¡ããããšãæ°ãããã¹ã¯ãŒããèŠæ±ãããŸãããã®ãã¹ã¯ãŒãã¯Yubikey 4ã«éä¿¡ãããŠåçïŒãã£ã¬ã³ãžã¬ã¹ãã³ã¹ã¢ãŒãïŒãäœæãããã·ã¹ãã ã®èµ·åæã«2èŠçŽ èªèšŒã«äœ¿çšã§ããŸãã
Yubikey 4ããŒã䜿çšãã2èŠçŽ èªèšŒ
- Yubikey 4ããŒãã³ã³ãã¥ãŒã¿ãŒã®USBã¹ãããã«æ¿å ¥ããŸãã
- ã³ã³ãã¥ãŒã¿ãŒã®é»æºãå ¥ããŸãã
- ãã¹ã¯ãŒãå ¥åãã£ãŒã«ãã«ãé話ãã¹ã¯ãŒãïŒyubikey-luks-enrollã¹ã¯ãªããã®å®è¡æã«äœæããããã¹ã¯ãŒãïŒãå ¥åããŸãã ããŒããŒãã®EnterããŒãæŒããŸãã
- YubikeyããŒã«é話ãã¹ã¯ãŒããéä¿¡ããå¿çãåä¿¡ãããšãLUKSããŒãã£ã·ã§ã³ã®æå·å解é€ããã»ã¹ãéå§ããããã®åŸãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãããŒããããŸãã
- 埩å·åããã»ã¹ãå®äºããããYubikey 4ããŒãUSBã¹ãããããåé€ã§ããŸãã
Yubikey 4ããŒã倱ãããïŒååšããªãïŒå Žåã§ãã以åã«å ¥åãããã¹ã¯ãŒããã¬ãŒãºã䜿çšããŠããŒãã£ã·ã§ã³ã埩å·åããããšãã§ããŸãã ãã¡ããããã¹ãã¬ãŒãºã以åã«å ¥åãããLUKSã»ã¯ã·ã§ã³ã®ã¹ãããã®1ã€ã«ä¿åãããŠããªãéãã
ãããã«
èªèšŒããã»ã¹ã®2çªç®ã®èŠçŽ ãšããŠYubikeyããã€ã¹ãããŒãšããŠäœ¿çšãããšãæå·åãããLUKSããŒãã£ã·ã§ã³ãæäœããã»ãã¥ãªãã£ãå€§å¹ ã«åäžããŸãã