Skip to content

Instantly share code, notes, and snippets.

@StephanX
Created November 3, 2016 21:18
Show Gist options
  • Save StephanX/2d71291df6c4aa278e80057690f79fb7 to your computer and use it in GitHub Desktop.
Save StephanX/2d71291df6c4aa278e80057690f79fb7 to your computer and use it in GitHub Desktop.
$ sudo apt-get install cryptsetup # or on redhat - yum install cryptsetup-luks
Reading package lists... Done
Building dependency tree
Reading state information... Done
cryptsetup is already the newest version (2:1.6.6-5ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 63 not upgraded.
$ truncate -s 100m myencryptedcontainer
$ cryptsetup -y -v luksFormat myencryptedcontainer
WARNING!
========
This will overwrite data on myencryptedcontainer irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:
Command successful.
$ sudo cryptsetup luksOpen ./myencryptedcontainer myencryptedfiles
Enter passphrase for ./myencryptedcontainer:
$ sudo mkfs.ext4 /dev/mapper/myencryptedfiles
mke2fs 1.43.1 (08-Jun-2016)
Creating filesystem with 100352 1k blocks and 25168 inodes
Filesystem UUID: 20e83401-5f8d-45d0-bfda-1d04599b6d92
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
$ mkdir myunencryptedsecrets
$ sudo mount /dev/mapper/myencryptedfiles /home/stephan/myunencryptedsecrets/
$ sudo chown -R stephan:stephan /home/stephan/myunencryptedsecrets/
$ echo "I'm some data" > /home/stephan/myunencryptedsecrets/somefile.txt
$ cat /home/stephan/myunencryptedsecrets/somefile.txt
I'm some data
$ sudo umount myunecryptedsecrets/
$ sudo cryptsetup luksClose myencryptedfiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment