Skip to main content

CryptSetup with encrypted file.


Cryptsetup uses dm-crypt to encrypt a disk at the partition level.  In RHEL, cryptsetup is used with Linux Unified Key Setup (LUKS), a disk encryption specification. Mounting a LUKS encrypted partiton requires a passphrase, which can either be passed in a file or via the command line. Read more about dm-crypt here.
Anyway to use crypsetup, you first must have a free partiton on a disk. In this instance I am using /dev/sdc1, which is a freeagent external usb drive.
First initialize the LUKS partition. My target is /dev/sdc1
#cryptsetup luksFormat /dev/sdc1
Then open the LUKS partition setup the dev mapper device. The command below creates /dev/mapper/freeagent
#cryptsetup luksOpen /dev/sdc1 chauhan
Create a passkey file if you want the device to be able to automount at boot. 
#vi /root/my.key && chmod 600 /root/my.key
Make cryptsetup aware of the key
#cryptsetup luksAddKey /dev/sdc1 /root/my.key
Dont forget to make a filesystem
#mkfs -t ext4 /dev/mapper/chauhan
Then add the following to /etc/fstab...
/dev/mapper/freeagent   /data             ext4    _netdev         1 1
And add the following to /etc/crypttab. Note that the first entry is the name of the /dev/mapper device
chauhan       /dev/sdc1       /root/my.key
To get a status on a device and to see the mappings between /dev/mapper and /dev/sdc1
#cryptsetup status
/dev/mapper/chauhan
/dev/mapper//dev/mapper/chauhan is active:
  cipher:  aes-cbc-essiv:sha256
  keysize: 128 bits
  device:  /dev/sdc1
  offset:  1032 sectors
  size:    2930270970 sectors
  mode:    read/write
Make sure you keep track of when to use /dev/mapper/freeagent vs /dev/sdc1 in the commands above.

Also check the crypttab status by.
#cryptsetup luksDump /dev/devicename



Comments

Popular posts from this blog

LINUX CONTAINERS

LINUX CONTAINERS What is Linux Container:  Linux containers have different approach than the Virtualization technology. Simply we can say this is OS level Virtualization, which means all containers run on top of one linux operating system.  We can start containers on a hardware running machine or inside of running virtual machine. Each container run's as a fully isolated operating sysem. In container virtualization rather than having an entire Operating System guest OS, containers isolate the guest but do not virtualize the hardware. For running containers one needs a patched kernel and user tools, the kernel provides process isolation and performs resource management. Thus all containers are running under the same kernel but they still have their own file system, processes, memory etc. Linux based containers mainly involved with two concepts: 1. Namespaces 2. Cgroups ( Controll Groups) There are total 6 types of Namespaces: 1. PID Na...

Setting up DNS service Add-On in kubernetes

Setting up DNS service Add-On in kubernetes What things get DNS names? Every Service defined in the cluster (including the DNS server itself) is assigned a DNS name. By default, a client Pod’s DNS search list will include the Pod’s own namespace and the cluster’s default domain. This is best illustrated by example: Assume a Service named “ my-service ” in the Kubernetes namespace “ dev ” . A Pod running in namespace “ dev ” can look up this service by simply doing a DNS query for “ my-service ” . A Pod running in namespace can look up this service by doing a DNS query for my-service.dev . Kubernetes offers a cluster addon for DNS service discovery, which most environments enable by default. “SkyDNS” seems to be the standard DNS server of choice, since it was designed to work on top of etcd. The “ kube-dns” addon is composed of a kubernetes service which, like all services, is allocated an arbitrary VIP within the preconfigured subnet (this is the IP that every other serv...

Canonical Kubernetes Platform

Recently,  Canonical has announce the release of the Canonical Kubernetes Platform version 1.32, a robust and user-friendly solution for seamless cluster creation and management. This platform is designed to simplify the deployment and maintenance of containerized workloads, making it an ideal choice for both developers and enterprises. Here are some of the attracting features of this Platform.  ZeroOps with Built-in Essentials:  The platform comes pre-configured with critical components such as networking, DNS, metrics server, local storage, ingress, gateway, and load balancer, enabling immediate productivity post-installation. Simplified Installation and Maintenance:   Leveraging snap packages, the installation process is straightforward, and automated patch upgrades enhance security without manual intervention. Effortless Scalability:  Adding new nodes is seamless, and achieving high availability requires minimal effort, ensuring your infrastructure sca...