Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15th December 2005, 09:04 PM
The_JinJ's Avatar
The_JinJ Offline
Registered User
 
Join Date: Dec 2005
Location: Glasgow
Age: 38
Posts: 2
Arrow HOWTO: Protect Files Using Encrypted Containers

Protecting Files Using Encrypted Containers

Prerequisites:

Kernel version 2.6.4-rc2 or higher.

root access for initial setup.

System Configuration

Enable the device-mapper module - lets you create new logical block devices from portions of existing devices. The block devices then are "mapped" to devices that for our use are treated like normal drive partitions.

Enable dm-crypt – (Crypt Target Support in the kernel configuration menu). dm-crypt is the kernel module used to handle the encryption/decryption using the crypto API available in the 2.6 version kernels.

To use an encrypted container for our files instead of an entire drive or partition, loopback device support also needs to be enabled in the kernel. The loopback device kernel module allows us to use ordinary files as if they were real block devices.

Compile or use module for the encryption type you want to use - AES encryption algorithm is used here but others are available.

Modules needed if compiling:
Device Drivers -> Multi-Device Support (RAID and LVM) -> Device Mapper Support
Device Drivers -> Multi-Device Support (RAID and LVM) -> Crypt Target Support
Device Drivers -> Block Devices -> Loopback Device Support
Cryptographic Options -> <encryption type>

Enable the required modules, compile the kernel and install it.
If you want to use modules dm-mod, dm-crypt and aes-i586
modprobe dm-mod
modprobe dm-crypt
modprobe aes

Now install these two sets of utitlites:
device-mapper utilities – if already installed then /dev/mapper and /dev/mapper/control will already exist.

cryptsetup utility - if the package is already installed /bin/cryptsetup will exist

Creating the Encrypted Container
Reboot with the new kernel (or make sure needed modules are loaded)

Create the container for your files and mount it.
Select a partition with enough space to create the container and make the container large enough for all the files you want in it (including new files!!) – it isn’t possible to increase the container size once created.

Use dd to create the container file
dd if=/dev/random of=/crypt/data.crypt bs=1M count=1024

bs is block size (1MB) and count is size in blocks (1GB 1024 X 1MB Blocks)

Source for the dd command is /dev/random - this makes it impossible to determine how much of the container is being used. It will be stored on /crypt
Create a loopback device using the container file.
If multiple containers are used you have to use a different /dev/loopX device (where X is a unique number)

losetup /dev/loop0 /crypt/data.crypt

Create the encrypted device
I used /dev/random to generate a 32-character random string password that I stored in a file named /home/crypt.key

cat /dev/random > /home/tkey (hit control-c after a second)
cat /home/tkey | cut -b 0-31 > /home/crypt.key
rm /home/tkey
cryptsetup -c aes -d /home/crypt.key create data.crypt /dev/loop0

To mount and use create a filesystem. This creates the ext2 filesystem (others can be used).
Once created mount like a normal drive partition.

mke2fs -j /dev/mapper/data.crypt
mkdir /mnt/encrypted
mount /dev/mapper/data.crypt /mnt/encrypted

Your encrypted device should act the same way that a normal drive partition does.

* You must remember to unmount the device and destroy the loopback setup when finished with the device!

umount /mnt/encrypted
cryptsetup remove data.crypt
losetup -d /dev/loop0

To recap – here’s how to remount the device:

losetup /dev/loop0 /crypt/data.crypt
cryptsetup -d /home/crypt.key create data.crypt /dev/loop0
mount /dev/mapper/data.crypt /mnt/encrypted
Reply With Quote
  #2  
Old 3rd September 2006, 10:54 PM
bruno2040 Offline
Registered User
 
Join Date: May 2005
Posts: 69
Hello,

Cryptsetup used to work fine with Fedora 3 and fedora 4.
I have juste upgraded to Fedora 5 and I cannot make Cryptsetup work anymore !

I have checked every detail that you put in your post. Evrything is correct (system configuration, container, loopback device...).
Here is what I obtain when I call cryptsetup:

>cryptsetup -c aes -y create toto /dev/loop0
Command failed: Argument invalide

Surpisingly, using the -v option does not give any more information.

Maybe it has something to do with SELinux ? For the first time, I didn t desactivate it at the Fedora installation .

Than ks for your help.
Reply With Quote
Reply

Tags
containers, encrypted, files, howto, protect

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!! how to password protect tar and zip files pnmanojshenoy Using Fedora 3 8th July 2008 07:24 AM
Uses for empty Cd blank containers? tashirosgt Wibble 12 28th November 2007 07:11 PM
Searching for Encrypted *.Zip Files TheEngineer Programming & Packaging 10 25th May 2007 08:03 PM
encrypted .pdf files satimis Using Fedora 0 10th December 2005 08:17 AM


Current GMT-time: 22:01 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat