Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have used cryptsetup to encrypt an external hard drive.

I have no problem at using the encrypted hard drive in this way:

/sbin/cryptsetup luksOpen /dev/sdc1 backup   
// typing password   
// mounting the partition   
// doing something   
// unmounting the partition  
/sbin/cryptsetup luksClose /dev/mapper/backup

But my next requirement was to be able to do it without the need of typing a password.

Then I created a binary file with the hash of my password via this command:

hashalot -n 32 ripemd160 > volume_key 

and then:

/sbin/cryptsetup luksOpen -d volume_key /dev/sdc1 backup

but I get this error:

Command failed: No key available with this passphrase.

Any ideas guys?

share|improve this question
    
but you never accept answers since your own edit? –  Rony May 16 '12 at 15:58

3 Answers 3

The contents of the volume_key file will be hashed by cryptsetup, so you don't need to do that yourself?

share|improve this answer
    
I think this is right; try using your incantation again, but put the passphrase itself in volume_key. –  MadHatter Dec 14 '10 at 17:49

In case you land here like I did looking for the answer, it goes like this:

Then I created a binary file with the hash of my password via this command:

 hashalot -n 32 ripemd160 > volume_key 

and then you must:

 /sbin/crypsetup luksAddKey volume_key 
 Enter any passphrase:   <- enter current passphrase aka: "typing password"

Now cryptsetup has added your file (volume_key) as another key to your volume. Technically, you can use any file you want for this key. A jpg image, or even any file full of random text.

Finally, now you can

 /sbin/cryptsetup luksOpen -d volume_key /dev/sdc1 backup

cryptsetup will use the key file if it is there, or ask for your passphrase if it cannot find the file.

share|improve this answer

cryptsetup man page suggests the following about the -d parameter: "If you want to set a new key via a key file, you have to use a positional arg to luksFormat or luksAddKey."

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.