How to mount a encrypted tar file in Linux?

1

1

Let us imagine I have encrypted my tar file with gpg as we can see here but I want to mount that with archivemount (e.g.: answer) without holding the unencrypted file on disk. Is it possible?

If not, Is there some way to create a encrypted disk image as a file to mount like we can see on EncryptedFilesystems?

Tiago Pimenta

Posted 2015-06-11T18:53:17.923

Reputation: 125

Answers

1

No, archivemount can’t do that. It doesn’t support GPG and neither does it support external filters/helpers.

LUKS works perfectly fine with file containers, using losetup and loop devices:

truncate -s 1G container.img
losetup -f # Use output in next commands
losetup /dev/loopX container.img
cryptsetup luksFormat /dev/loopX
cryptsetup luksOpen /dev/loopX mycontainer # ...where “mycontainer” is a free name in /dev/mapper/

Then proceed to create a filesystem and whatnot. When you’ve finished using the container, close it:

cryptsetup luksClose /dev/mapper/mycontainer

And remove the loop device mapping.

losetup -d /dev/loopX

Daniel B

Posted 2015-06-11T18:53:17.923

Reputation: 40 502

It took me a time to format, It's better to use luksformat -t ext4 /dev/loopX instead of cryptsetup luksFormat /dev/loopX. – Tiago Pimenta – 2015-06-11T20:55:03.170