SlideShare a Scribd company logo
Linux encrypted Container
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Guide for Ubuntu 12.04/14.04
Quickly create an encrypted drive to store your confidential
data under Linux. This guide provides the quick steps!
Preparation
**Commands to be executed are in black
#install cryptsetup
sudo apt-get install cryptsetup
#creating the file as the container (5G in this example)
sudo fallocate -l 5G /root/container.bin
#list all loopback device on the system and choose one free
#in our example we choose /dev/loop0
sudo ls -liha /dev/loop*
#bind the container to the loopback device
#if we get an error using /dev/loop0
#we can use /dev/loop1 (and adjust subsequent #commands according to our choice)
sudo losetup /dev/loop0 /root/container.bin
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Adjust the container
**Commands to be executed are in black
#run fdisk to adjust the partition table
sudo fdisk /dev/loop0
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x20ce46d0.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-1023999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1023999, default 1023999):
Using default value 1023999
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Encrypt the container
**Commands to be executed are in black
#let’s encrypt the container and create a passphrase to secure access to container
cryptsetup --verbose --verify-passphrase luksFormat /dev/loop0
WARNING!
========
This will overwrite data on /dev/loop0 irrevocably.
Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase: *********************
Command successful..
**--verbose (show visual output) --verify-passphrase (ask twice the passphrase for
confirmation)
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Connect block device and format
**Commands to be executed are in black
#mount the container to /dev/mapper/container
cryptsetup luksOpen /dev/loop0 container
Enter passphrase for /dev/loop0:
#format the container
mkfs.ext4 -j /dev/mapper/container
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Mount the volume
**Commands to be executed are in black
#create the folder we will use to mount the volume (may automatically mount)
mkdir /mnt/cryptvolume
#mount the volume (may automatically mount)
mount /dev/mapper/container /mnt/cryptvolume
#Look at the volume we just mounted
df -h
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
Closing the volume
**Commands to be executed are in black
#when finished working with the volume, it is suggested to close it
cryptsetup luksClose container
#look to make sure our device “container” is now closed
#the control device is a device that is used to create other mapped devices
#we can safely ignore this, as it is supposed to be here.
ls /dev/mapper
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
How to use it daily?
**Commands to be executed are in black
#open the container and provide the passphrase
sudo cryptsetup luksOpen /root/container.bin container
#mount the volume (may automatically mount)
sudo mount /dev/mapper/container /mnt/cryptvolume
#unmount the volume when finish working with sensitive data
sudo umount /dev/mapper/container
#close the container to keep file secure from access
sudo cryptsetup luksClose container
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1
References
Encrypted Containers Without TrueCrypt, Eric Hansen, Moderator at linux.org.
http://www.linux.org/threads/encrypted-containers-without-truecrypt.4478/
LUKS: Disk Encryption
https://guardianproject.info/code/luks/
How To Use DM-Crypt to Create an Encrypted Volume on an Ubuntu VPS - DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-use-dm-crypt-to-create-an-encrypted-volume-on-an-
ubuntu-vps
Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM
LinkedIn: http://ca.linkedin.com/in/herouxma
Twitter: @herouxma
08/25/2017 / Version 1.1

More Related Content

PDF
2018 - CertiFUNcation - Helmut Hummel: Hardening TYPO3
PPTX
Flex pod driven by Openstack
PDF
軽快なPlan9 (第三回Kernel/VM探検隊)
PDF
using Virtualbox NAT and shared folder
PDF
My First BCC
PDF
PDF
Microsoft Docker Meetup - Tutum Spring 2015
PDF
Open ZFS Keynote (public)
2018 - CertiFUNcation - Helmut Hummel: Hardening TYPO3
Flex pod driven by Openstack
軽快なPlan9 (第三回Kernel/VM探検隊)
using Virtualbox NAT and shared folder
My First BCC
Microsoft Docker Meetup - Tutum Spring 2015
Open ZFS Keynote (public)

What's hot (20)

PDF
Linux kernel vs user space - Hervé Nicol (GFI)
TXT
Determine 64 or 32 bit unix kernel and hw
DOCX
Proxy server ubuntu 12.04
PDF
LinuxをインストールしてWebサーバーを立ち上げてみよう【OSC2018 Tokyo/Spring】
DOC
Juniper防火墙case信息收集表
KEY
zhng your vim
PPTX
Cassandra on Ubuntu AUTOMATIC Install
PDF
redis-benchmark with AMD RYZEN 1800X Intel Kaby Lake (i7-7700K) memo
PDF
Scaling IO-bound microservices
PDF
How to train your L3DSR with PBR - MEMO -
PDF
Creación de máquinas virtuales basada en kernel usando qemu y virsh
PDF
Linux kernel bug hunting
PDF
3 manual installation of open vpn
PDF
How to install OpenStack MITAKA --allinone - cheat sheet -
PDF
今日から始めるPlan 9 from Bell Labs
PPTX
EKFiddle: a framework to study Exploit Kits
PDF
Kernel Recipes 2013 - kconfig-frontends, a packaging of the kconfig parser an...
PPTX
Rasperry Pi and TI CC2650 IPv6 border router
PDF
IL: 失われたプロトコル
PDF
Running Docker with OpenStack | Docker workshop #1
Linux kernel vs user space - Hervé Nicol (GFI)
Determine 64 or 32 bit unix kernel and hw
Proxy server ubuntu 12.04
LinuxをインストールしてWebサーバーを立ち上げてみよう【OSC2018 Tokyo/Spring】
Juniper防火墙case信息收集表
zhng your vim
Cassandra on Ubuntu AUTOMATIC Install
redis-benchmark with AMD RYZEN 1800X Intel Kaby Lake (i7-7700K) memo
Scaling IO-bound microservices
How to train your L3DSR with PBR - MEMO -
Creación de máquinas virtuales basada en kernel usando qemu y virsh
Linux kernel bug hunting
3 manual installation of open vpn
How to install OpenStack MITAKA --allinone - cheat sheet -
今日から始めるPlan 9 from Bell Labs
EKFiddle: a framework to study Exploit Kits
Kernel Recipes 2013 - kconfig-frontends, a packaging of the kconfig parser an...
Rasperry Pi and TI CC2650 IPv6 border router
IL: 失われたプロトコル
Running Docker with OpenStack | Docker workshop #1
Ad

Similar to Linux encrypted container (20)

PDF
MINCS - containers in the shell script (Eng. ver.)
PDF
The Container Security Checklist
PDF
Docker, Linux Containers (LXC), and security
PDF
Docker, Linux Containers, and Security: Does It Add Up?
PDF
Zombies in Kubernetes
PDF
Webinar: Automate IBM Connections Installations and more
PPTX
Secure container: Kata container and gVisor
PDF
Real-World Docker: 10 Things We've Learned
PDF
Docker Security in Production Overview
PPT
Top ESXi command line v2.0
PDF
Demystifying docker networking black magic - Lorenzo Fontana, Kiratech
PDF
How Secure Is Your Container? ContainerCon Berlin 2016
KEY
the NML project
PPT
Andresen 8 21 02
PDF
LXC, Docker, security: is it safe to run applications in Linux Containers?
PDF
Digital Forensics and Incident Response in The Cloud Part 3
PDF
Introduction to Docker and Containers
PDF
Xen time machine
PDF
Rootless Containers
PDF
CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015
MINCS - containers in the shell script (Eng. ver.)
The Container Security Checklist
Docker, Linux Containers (LXC), and security
Docker, Linux Containers, and Security: Does It Add Up?
Zombies in Kubernetes
Webinar: Automate IBM Connections Installations and more
Secure container: Kata container and gVisor
Real-World Docker: 10 Things We've Learned
Docker Security in Production Overview
Top ESXi command line v2.0
Demystifying docker networking black magic - Lorenzo Fontana, Kiratech
How Secure Is Your Container? ContainerCon Berlin 2016
the NML project
Andresen 8 21 02
LXC, Docker, security: is it safe to run applications in Linux Containers?
Digital Forensics and Incident Response in The Cloud Part 3
Introduction to Docker and Containers
Xen time machine
Rootless Containers
CloudStack hands-on workshop @ DevOpsDays Amsterdam 2015
Ad

More from Marc-Andre Heroux (9)

PDF
IT Control Framework
PPTX
Enterprise Security Critical Security Functions version 1.0
PPTX
Online Authentication
PDF
Monitoring your organization against threats - Critical System Control
PPTX
Frame - MAC Address Threats & Vulnerabilities
PPTX
Modèle de sécurité organisationnelle
PPT
Méthodologie - adoption d'une norme en 7 étapes
PPTX
BUSINESS MATURITY LIFE CYCLE
PPTX
Assurance compliance management system
IT Control Framework
Enterprise Security Critical Security Functions version 1.0
Online Authentication
Monitoring your organization against threats - Critical System Control
Frame - MAC Address Threats & Vulnerabilities
Modèle de sécurité organisationnelle
Méthodologie - adoption d'une norme en 7 étapes
BUSINESS MATURITY LIFE CYCLE
Assurance compliance management system

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Getting Started with Data Integration: FME Form 101
PDF
project resource management chapter-09.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
A Presentation on Touch Screen Technology
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Mushroom cultivation and it's methods.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
cloud_computing_Infrastucture_as_cloud_p
Encapsulation theory and applications.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Univ-Connecticut-ChatGPT-Presentaion.pdf
Chapter 5: Probability Theory and Statistics
DP Operators-handbook-extract for the Mautical Institute
Getting Started with Data Integration: FME Form 101
project resource management chapter-09.pdf
1. Introduction to Computer Programming.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
A novel scalable deep ensemble learning framework for big data classification...
A Presentation on Touch Screen Technology
A comparative study of natural language inference in Swahili using monolingua...
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Mushroom cultivation and it's methods.pdf
Encapsulation_ Review paper, used for researhc scholars
Hindi spoken digit analysis for native and non-native speakers
cloud_computing_Infrastucture_as_cloud_p

Linux encrypted container

  • 1. Linux encrypted Container Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1 Guide for Ubuntu 12.04/14.04 Quickly create an encrypted drive to store your confidential data under Linux. This guide provides the quick steps!
  • 2. Preparation **Commands to be executed are in black #install cryptsetup sudo apt-get install cryptsetup #creating the file as the container (5G in this example) sudo fallocate -l 5G /root/container.bin #list all loopback device on the system and choose one free #in our example we choose /dev/loop0 sudo ls -liha /dev/loop* #bind the container to the loopback device #if we get an error using /dev/loop0 #we can use /dev/loop1 (and adjust subsequent #commands according to our choice) sudo losetup /dev/loop0 /root/container.bin Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 3. Adjust the container **Commands to be executed are in black #run fdisk to adjust the partition table sudo fdisk /dev/loop0 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x20ce46d0. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): Using default value 1 First sector (2048-1023999, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-1023999, default 1023999): Using default value 1023999 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 4. Encrypt the container **Commands to be executed are in black #let’s encrypt the container and create a passphrase to secure access to container cryptsetup --verbose --verify-passphrase luksFormat /dev/loop0 WARNING! ======== This will overwrite data on /dev/loop0 irrevocably. Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: Verify passphrase: ********************* Command successful.. **--verbose (show visual output) --verify-passphrase (ask twice the passphrase for confirmation) Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 5. Connect block device and format **Commands to be executed are in black #mount the container to /dev/mapper/container cryptsetup luksOpen /dev/loop0 container Enter passphrase for /dev/loop0: #format the container mkfs.ext4 -j /dev/mapper/container Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 6. Mount the volume **Commands to be executed are in black #create the folder we will use to mount the volume (may automatically mount) mkdir /mnt/cryptvolume #mount the volume (may automatically mount) mount /dev/mapper/container /mnt/cryptvolume #Look at the volume we just mounted df -h Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 7. Closing the volume **Commands to be executed are in black #when finished working with the volume, it is suggested to close it cryptsetup luksClose container #look to make sure our device “container” is now closed #the control device is a device that is used to create other mapped devices #we can safely ignore this, as it is supposed to be here. ls /dev/mapper Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 8. How to use it daily? **Commands to be executed are in black #open the container and provide the passphrase sudo cryptsetup luksOpen /root/container.bin container #mount the volume (may automatically mount) sudo mount /dev/mapper/container /mnt/cryptvolume #unmount the volume when finish working with sensitive data sudo umount /dev/mapper/container #close the container to keep file secure from access sudo cryptsetup luksClose container Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1
  • 9. References Encrypted Containers Without TrueCrypt, Eric Hansen, Moderator at linux.org. http://www.linux.org/threads/encrypted-containers-without-truecrypt.4478/ LUKS: Disk Encryption https://guardianproject.info/code/luks/ How To Use DM-Crypt to Create an Encrypted Volume on an Ubuntu VPS - DigitalOcean https://www.digitalocean.com/community/tutorials/how-to-use-dm-crypt-to-create-an-encrypted-volume-on-an- ubuntu-vps Marc-Andre Heroux, CGEIT, CISA, CRMA, CRMP, ABCP, CISSP, NSA-IAM, NSA-IEM LinkedIn: http://ca.linkedin.com/in/herouxma Twitter: @herouxma 08/25/2017 / Version 1.1