what is the most efficient way of unlocking a LUKS drive over the network when using key files?

Nick Sandor asked:

It is easy to unlock a LUKS drive over SSH when the drive takes text passwords:

cryptsetup luksOpen /dev/sdb1 mylockeddrive

Then entering the password at prompt.

Is there a way of unlocking these drives when a key file is used, short of copying the key file on the remote system?

My answer:

Send the key via a pipe and tell cryptsetup to read it from standard input.

cat keyfile | ssh remotehost "cryptsetup open --type luks --key-file - /dev/sdb1"

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.