LinuxQuestions.org
Social Bookmarking all things Linux and Open Source
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Tags used in this thread
Popular LQ Tags

Reply
 
Thread Tools Search this Thread
Old 02-02-2007, 06:04 AM   #1
vijaush
LQ Newbie
 
Registered: Feb 2007
Posts: 8
Thanked: 0
Unhappy Encrypting the usb flash drive


[Log in to get rid of this advertisement]
Hi all,

i want to encrypt the data stored on the usb mass storage device( sector wise ), but i cannot figure out where to start digging. i have tried to search in devio.c and hcd.c in /usr/src/kernel/drivers/usb/core but with no success

can anyone please tell me where should i look for getting the data encrypted in the usb mass storage device.

thanks in advance
vijaush is offline  
Tag This Post
Reply With Quote
Old 02-02-2007, 08:36 AM   #2
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian, Fedora
Posts: 804
Blog Entries: 1
Thanked: 12
I uses GPG manually to encrypt my files.
ramram29 is offline     Reply With Quote
Old 02-02-2007, 09:51 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,313
Thanked: 3
If you want to encrypt the complete disk, you need
*Kernel >=2.6.4 (>=2.6.10 for better security)
*BLK_DEV_DM and DM_CRYPT options enabled in the kernel
*cryptsetup utility

/dev/sda being your usb key:

Verify disk and put random data (for security on known clear text attacks):
Code:
/sbin/badblocks -s -w -t random -v /dev/sda
dd if=/dev/urandom of=/dev/sda
Format the key with ext2 filesystem encrypted using luks, password is asked:
Code:
luksformat -t ext2 /dev/sda
Create a mount point where your decrypted disk will be mounted:
Code:
mkdir /media/cdisk1
Its more coherent with the rest of the howto if you put it in /media. Also media is the standard for removable media (its not supposed to be always mounted)


Link it with a device mapper, put this in /etc/fstab:
Quote:
/dev/mapper/cdisk1 /media/cdisk1 ext2 noauto,defaults 0 0
Tell the system that /dev/sda is to be linked with /dev/mapper/cdisk1, put this in /etc/crypttab:
Quote:
cdisk1 /dev/sda none luks,timeout=10
Mount it with the next command, password is asked:
Code:
cryptsetup luksOpen /dev/sda cdisk1
mount /media/cdisk1
To unmount and remove the mapping:
Code:
 umount /media/cdisk1
 cryptsetup luksClose cdisk1
Customization:
On next reboot, /etc/init.d/cryptdisks (in case it is installed by cryptsetup) will look in /etc/crypttab, ask you for the password and mount the disk in /media/cdisk1

Alternatively to mount it you can use pmount. The first argument is the partition or disk, the second is a label you choose (it can be different from above)
Code:
pmount /dev/sda supa_crypt
pmount will try to guess the filesystem and as it knows luks (because luks is a standard), will mount the disk in /media/supa_crypt
To use pmount on a non-removable media (eg. /dev/hda6 below), you have to allow this device to be "pmounted":
Quote:
Originally Posted by pmount.allow
# /etc/pmount.allow
# pmount will allow users to additionally mount all devices that are
# listed here.
/dev/hda6

If your HAL and udev is configured correctly and your Window manager is HAL-aware, just plug in the usb key and a popup appears to ask you the password. (the media will be mounted in /media/sda in this case, the label is the partition name)

And here are other links:
https://www.debian-administration.org/articles/428
https://www.debian-administration.org/articles/469
https://www.debian-administration.org/articles/179
http://cvs.lp.se/doc/cryptsetup/usbcrypto.hotplug.gz
http://cvs.lp.se/doc/cryptsetup/ <- you can encrypt the swap, encrypt the full system, etc..
https://www.debian-administration.org/articles/475 <-- truecrypt but it is not standard and not GPL. For it to work, you only need BLK_DEV_DM in the kernel. There are people who have made packages for several distro.

Last edited by nx5000; 02-07-2007 at 01:08 PM..
nx5000 is offline     Reply With Quote
Old 02-06-2007, 12:01 AM   #4
vijaush
LQ Newbie
 
Registered: Feb 2007
Posts: 8
Thanked: 0

Original Poster
thank you guys !!!
vijaush is offline     Reply With Quote
Old 02-06-2007, 01:12 PM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,313
Thanked: 3
I've tested and updated the post.
nx5000 is offline     Reply With Quote
Old 02-07-2007, 10:21 AM   #6
vijaush
LQ Newbie
 
Registered: Feb 2007
Posts: 8
Thanked: 0

Original Poster
thanks a lot
vijaush is offline     Reply With Quote
Old 10-01-2007, 03:15 PM   #7
statguy
Member
 
Registered: Sep 2004
Location: Ontario, Canada
Distribution: Slackware 12.2
Posts: 254
Thanked: 1
I came across this useful thread today. I have one question about this procedure. Will this in any way break the usage of "standard" non-encrypted USB keys?
statguy is offline     Reply With Quote

Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Pen Drive / Flash Drive Unmounted but the power is there teluguswan Linux - Hardware 11 10-04-2008 04:36 PM
USB flash drive (Pen drive) mounts read only prabhatsoni Linux - Hardware 24 07-02-2007 02:28 PM
cannot delete drive from root desktop - cannot mount usb flash drive - openSuSE 10.2 bluecog6 Linux - General 6 01-29-2007 04:18 PM
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 2 06-09-2006 10:56 AM
USB Flash drive ddu_ Linux - Newbie 3 03-11-2006 08:13 PM


All times are GMT -5. The time now is 06:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration