🔹Encryption
LUKS
You can implement LUKS only before system installation because LUKS is an FDE solution and your file system will be implemented on top of it, so there is no way to setup LUKS on a system with installed OS.
create a linux partition:
create an encryption layer on top of /dev/sdb1
open the device with the given name in /dev/mapper
for automatic mount of the encrypted device we have to create a config file and an entry in /etc/fstab:
nano /etc/crypttab
add following:
nano /etc/fstab
add following:
reboot
GNU Privacy Guard (GPG)
create key pair:
list keys:
Symmetrically Encrypting Files
the -c option indicates that I chose to use symmetric encryption with a passphrase for the file. The passphrase that you enter will be for the file, not for your private key.
decryption:
Encrypting Files with Public Keys
after creating key pairs on both ends, extract your own public keys into an ASCII text file.
do this on both ends
export pubkeys
Normally, the participants in this would send their keys to each other either through an email attachment or by placing the keys in a shared directory place these pub keys into your respective .gnupg directories. Once that's done, import each other's keys.
encrypt your file:
send the file
decrypt and open the file on the other side:
to add the pub key to the trusted keys:
Signing a File Without Encryption
If a file isn't secret but you still need to ensure authenticity and integrity, you can just sign it without encrypting it the pub key exchange should be done before doing this:
Create an unencrypted message and sign it:
Send the message, try to open it with less:
There's a lot of gibberish there because of the signature, but if you look carefully,you'll see the plain, unencrypted message.
use gpg with the --verify option to verify that the signature really does belong to you:
eCryptfs
Red Hat and CentOS no longer include eCryptfs in either version 7 or 8 of their products.
Encrypting a Home Directory for a New User Account
install the ecryptfs-utils package:
create Goldie's account with an encrypted directory:
Have Goldie log in. Have her unwrap her mount passphrase, write it down, and store it in a secure place. She'll need it if she ever needs to recover a corrupted directory:
Creating a Private Directory Within an Existing Home Directory
Instead of encrypting an entire home directory, any user can create an encrypted private directory within his or her own home directory
Encrypting the swap Partition with ecryptfs
Don't mind the warning about the missing /dev/mapper/cryptswap1 file. It will get created the next time you reboot the machine.
VeraCrypt (cross-platform)
VeraCrypt is the successor to TrueCrypt, and it allows the sharing of encrypted containers across Linux, Windows, macOS, and FreeBSD machines. Although LUKS and eCryptfs are good, VeraCrypt does offer more flexibility in certain ways:
As mentioned, VeraCrypt offers cross-platform sharing, whereas LUKS and eCryptfs don't.
VeraCrypt allows you to encrypt either whole partitions or whole storage devices, or to create virtual encrypted disks.
Not only can you create encrypted volumes with VeraCrypt, you can also hide them, giving you plausible deniability.
VeraCrypt comes in both command-line and GUI variants, so it's appropriate for either server use or for the casual desktop user.
Like LUKS and eCryptfs, VeraCrypt is free open source software, which means that it's free to use, and that the source code can be audited for either bugs or backdoors.
Download VeraCrypt from here:
creating and mounting a VeraCrypt volume in console mode
To create a new encrypted volume
This will take you into an easy-to-use interactive utility. For the most part, you'll be fine just accepting the default options
Mount this container in order to use it. Begin by creating a mount point directory
To see what VeraCrypt volumes you have mounted
OpenSSL
With OpenSSL, we can encrypt information on the fly as it goes across the network. There's no need to manually encrypt our data before we send it across the network because OpenSSL encryption happens automatically. This is important because online commerce and banking couldn't exist without it.
generating rsa key:
see the key structure:
separate public key from key file:
generate DSA key
generate an ECDSA key :
OpenSSL supports many named curves (you can get a full list with the -list_curves switch), but, for web server keys, you’re limited to only two curves that are supported by all major browsers: secp256r1 (OpenSSL uses the name prime256v1 ) and secp384r1 .
Creating Certificate Signing Requests
check the CSR:
generate a public and private key pair:
That generates a 2048-bit RSA key pair, encrypts them with a password you provide and writes them to a file. You need to next extract the public key file. You will use this, for instance, on your web server to encrypt content so that it can only be read with the private key.
create a 2048-bit private key (domain.key) and a CSR (domain.csr) from scratch:
Generate a CSR from an Existing Private Key
Generate a Self-Signed Certificate
Generate a Self-Signed Certificate from an Existing Private Key
Generate a Self-Signed Certificate from an Existing Private Key and CSR
View Certificate Entries
Verify a Certificate was Signed by a CA
Create a Private Key
Verify a Private Key
Verify a Private Key Matches a Certificate and CSR
Encrypt a Private Key
Last updated