date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,479,187,367,000
As part of my job I often find myself transferring lots of files between my computer and a remote storage space accessible over SFTP. To ensure the files' correct transfer I compute their SHA256 hashes prior to transferring them, transfer them, then verify these hashes on my computer. However, this can be very lengthy since I often download several gigabytes on my computer from the remote storage. Now, I have been curious about forcing SCP to use HMAC-RIPEMD160 to ensure message integrity (-o MACs=hmac-ripemd160). It's the strongest HMAC supported by my servers, and admittedly it is weaker than SHA256, but if I rely on SSH's own mechanisms to ensure message integrity, in principle it should be enough to not have to spend a long time calculating and then verifying file hashes when transferring stuff. So, to wrap it up: can I replace computing and verifying file hashes with using SCP with HMAC-RIPEMD160?
SSH establishes a secure channel between the client and the server. This means that any corruption of the file (accidental or malicious) will be detected. You do not need to do anything special! The only thing you need to do is to check that the return value of the scp or sftp command is 0, indicating success. If scp or sftp indicates success, then the file has been transferred successfully. Any verification you might do by a hash computation would be redundant. The MACs option controls which MAC SSH uses as part of its secure channel protocol. It is extremely rare to need to change that setting: the client and the server will negotiate an algorithm that they both support. To wrap it up: you can replace computing and verifying the hashes by verifying the return status of scp or sftp.
Can using SFTP with HMAC-RIPEMD160 replace computing file hashes before and after transferring?
1,479,187,367,000
I am trying to verify this hashed password from my /etc/shadow file: $y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90 I would like to pass the hash to mkpasswd this way but it fails: $ mkpasswd -m yescrypt secret eia4V8bEUD9QBJAEwilXU. Wrong salt length: 22 bytes when 0 expected. $ mkpasswd -m yescrypt secret "$y$j9T$eia4V8bEUD9QBJAEwilXU.$" crypt: Invalid argument How can I pass the salt or parameters from the hashed string? By the way, I have found a way to verify the password with a python script as described in this SO post, so it means we have enough info (parameters and salt) to compute the hash. But I would prefer to do it with mkpasswd: $ python3 -c 'import crypt, os; print(crypt.crypt("secret", "$y$j9T$eia4V8bEUD9QBJAEwilXU.$"))' $y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90
If you pass the salt (eg with -S or as the second param) and include the $ settings then you don't need to specify the method % mkpasswd -S '$y$j9T$eia4V8bEUD9QBJAEwilXU.' secret $y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90 % mkpasswd secret '$y$j9T$eia4V8bEUD9QBJAEwilXU.' $y$j9T$eia4V8bEUD9QBJAEwilXU.$TLUJexdhrx/q3Nc/YaCrlkVkrxUkimYn3o432pxFr90
How to pass a salt to mkpasswd with yescrypt algorithm
1,479,187,367,000
There are many tips on how to resize (increase) a LUKS2 encrypted device / partition / LVM volume. But how to increase the size of the LUKS container created in the file? I once created: dd if=/dev/random of=/some file bs=1M count=100 cryptsetup luksFormat /some-file cryptsetup luksOpen /some-file some-mount mkfs.ext4 /dev/mapper/some-mount Now this container has run out of space and I need to increase its size. How to do it?
You can just set a new file size with truncate, then cryptsetup resize and resize2fs. For example, setting it to 200M: truncate -s 200M cryptfile.img Alternatively, if you prefer dd or other tools, you can just append another 100M of random data: head -c 100M /dev/urandom >> cryptfile.img Warning: if you truncate to a too small size, or if you typo and use > instead of >>, your data would be lost. dd in particular likes to truncate files to 0 bytes by default, and it's easy to make mistakes, so I don't really recommend using it here. The difference between truncate and appending random data is that truncate makes sparse files (zero, unallocated) while appending properly allocates space and initializes it with random data. Then you can online resize the mapping (this might ask for your passphrase again): cryptsetup resize cryptname This would also happen automatically next time you cryptsetup open the container normally. At this point the encrypted block device (loop device, image file) should be properly resized to 200M (minus 16M or whatever is the size of your LUKS header). That leaves the filesystem: resize2fs /dev/mapper/cryptname
How to increase the size of a LUKS file-container
1,479,187,367,000
I have the following partition table: NAME nvme0n1 ├─nvme0n1p1 part /boot └─nvme0n1p2 part └─crypt crypt ├─crypt-swap lvm [SWAP] ├─crypt-root lvm / └─crypt-home lvm /home As the drive is an SSD, I would like to perform TRIM command in order to increase performance/lifetime of the disk itself. In particular, I would like to enable periodic TRIM. Because the second partition (i.e., nvme0n1p2) is encrypted, TRIM will be inhibited because of security implications (https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD)). However, it is possible to enable TRIM on encrypted partition by configuring encrypt on the opening. As I my partition is opened at kernel boot, I've modified kernel parameters (i.e., allow-discards): cryptdevice=/dev/sdaX:root:allow-discards (Note that the partition naming and volume name are not relevant in the above snippet.). By doing that, I was indeed successfully able to run TRIM command on the disk: # cryptsetup luksDump /dev/nvme0n1p2 | grep Flags Flags: allow-discards And: # fstrim ... /home: [..] trimmed on ... /: [..] trimmed on So far, so good. The problem arose when I tried to restore to the original state. I have removed the kernel parameter allow-discards, but Flags on partition still shows allow-discards and fstrim command successfully complete its job. How is that possible? How to restore denying of discards on the encrypted partition?
It turned out, LUK2 can permanently store metadata in the header. It is possible to enable allow-discards and store in the partition itself (without any further configuration -e.g., kernel parameters) with the command: cryptsetup --allow-discards --persistent refresh root Evidently, I issued this command in the past enabling the discarding option. It is possible to remove the flag with: cryptsetup --persistent refresh root https://man7.org/linux/man-pages/man8/cryptsetup.8.html Refreshing the device without any optional parameter will refresh the device with default setting (respective to device type).
Disable allow-discards on encrypted partition
1,479,187,367,000
Pardon me if this is not possible. My goal is to utilise pass. From the conducted research, it appears that the pass command utility will require a GPG key before you can store your sensitive data. Now, in order to generate a GPG key, one would run the following command gpg --full-generate-key which is a pre-requisite to using pass. From the output, we can see that the options to choose from are as follows: gpg (GnuPG) 2.2.27; Copyright (C) 2021 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. gpg: directory '/home/user1/.gnupg' created gpg: keybox '/home/user1/.gnupg/pubring.kbx' created Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) (14) Existing key from card Your selection? As you can see, you can use RSA or DSA, despite GPG specifying that you can use AES256. gpg (GnuPG) 2.2.27 libgcrypt 1.8.8 Copyright (C) 2021 Free Software Foundation, Inc. License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: /home/user1/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2 Does that mean it is impossible to secure your passwords in pass using AES256 encryption method?
What you are trying to do is unfortunately not possible. AES256 is a symmetric-key algorithm, i.e. the same key is used for encrypting and decrypting. The --generate-key or --full-generate-key option of gpg is used to create an asymmetric public/private key pair, where the public key is used for encryption and the private key for decryption. Note that AES256 is listed under the options for "Cipher", not "Pubkey". That said, I can understand that you would prefer the higher security level of AES256 over RSA. It seems however that the ECDSA and ED25519 algorithms can provide similar security to AES256. To enable it in gpg2, you will need to specify the --expert option. When asked "what kind of key you want", choose (9) ECC and ECC with either NIST P-256 or Curve 25519, respectively. Both curve algorithms provide the same level of security, with ED25519 being a tiny bit faster than ECDSA.
How to specify AES-256 algorithm when creating GPG key?
1,479,187,367,000
This sounds very dumb but hear me out (though it still may be). I'm a CS student. And the collage I study in have the bright idea of blocking all incommoding SSH and VPN traffic in the name of security. Then asks all persional to go through an out-of-date and exploitable OpenVPN server to reach behind the firewall. Which made my life difficult. I want to reach my lab server from my home. But not through the old OpenVPN server. --------------- --------------- ----------------- | My home PC | ---> | Firewall | -X---> | Lab server | --------------- --------------- ----------------- The entire thing sounds stupid to me (I'd argue someone using default passwords being a bigger issue. Anyway). I decided to figure out how solid the firewall is. Then I found that encrypting my traffic through rot13 is good enough to fool the firewall. --------------- --------------- ----------------- | My home PC |->| rot13 | ---> | Firewall | -----> | rot13 | -> | Lab server | --------------- --------------- ----------------- Here's my PoC: # Client side: nc -l -p 2222 | rot13 | nc my_server_ip 2222 # server side: nc -l -p 2222 -s my_server_ip | rot13 | nc localhost 22 Which does get the SSH handshake going when I connect to localhost 2222. But this is a one way link therefore the handshake doesn't complete. (contrast to the handshake packet doesn't even arrive without rot13). The question is, this is an encrypted one way link. How could I make it bidirectional? So far I tried to pipe data from iptables to rot13 and back. But I can't. Notes I'm not considering obfuscating proxies like obfsproxy since this should be easy. Don't want to use the heavy duty weapons. ROT13 is only there to bypass the firewall. I'm aware that it's weak. This is a question of "Hmm... could I do this?" not "should I do this?"
socat should do. The socat tool takes care of all your needs to (bidirectionally) pipe anything anywhere. It just takes a pair of arguments, each specifying one of the things to connect together. The most interesting options in this case are TCP:host:port, TCP-LISTEN:port and FD: or OPEN:. Each argument can also be composed of a pair of these separated by !!, where the first element will be read and the other one will be written. A minimal extension to your nc-based example could thus look something like this: Server end: mkfifo in in_rot out out_rot rot13 < in > in_rot & rot13 < out > out_rot & socat TCP:localhost:22 OPEN:in_rot!!OPEN:out & socat TCP-LISTEN:2222 OPEN:out_rot!!OPEN:in & This can be simplified by getting rid of the named FIFOs and using FD: to refer to pipes set up in Bash. As written, this would only be good for a single use (socat will exit once the connections get closed). You can either run it in an infinite loop, or set up a systemd .socket unit or something like xinetd to do the listening for you and spawn this script upon connection. The client end can be done in a very similar way (listening on some local port and connecting to the server on 2222), or you can omit the TCP-LISTEN part and instead run the whole thing as a ProxyCommand from ssh (you can then put that into your .ssh/config and use ssh as if there was no tunnel). Should you ever want to tunnel more than just a SSH connection, note that socat also has the TUN: option that will give you a full-blown tunnel interface, so you can then trivially turn this into a real VPN.
Apply rot13 (or other encryption) to all forwarded traffic on port
1,479,187,367,000
When I run iw phy I see the list of ciphers my interface supports, Supported Ciphers: * WEP40 (00-0f-ac:1) * WEP104 (00-0f-ac:5) * TKIP (00-0f-ac:2) * CCMP-128 (00-0f-ac:4) * GCMP-128 (00-0f-ac:8) * GCMP-256 (00-0f-ac:9) * CMAC (00-0f-ac:6) * GMAC-128 (00-0f-ac:11) * GMAC-256 (00-0f-ac:12) How do I find what cipher the card is using on the currently connected network?
Try to run wpa_cli (or sudo wpa_cli). Then type: scan scan_result scan_result should print what kind of encryption wifi networks in your vicinity use. You know to which one you are connected, so that is your used encryption method. You can know something even before that as you know that CCMP and GCMP are used in WPA2-AES, etc. scan_result will also show you the cipher of the currently connected network, hiding other networks you're not connected to $ sudo wpa_cli scan_result Selected interface 'wlp0s20f3' bssid / frequency / signal level / flags / ssid b2:75:1c:22:d9:c0 5180 -32 [WPA2-PSK-CCMP][ESS][UTF-8] EvanCarroll_5G You can also try this: iwlist <adapter> scan In my case iwlist wlp1s0 scan
How can I get the active cipher for a wireless interface?
1,479,187,367,000
Say I encrypt a file using my private GPG key on my desktop. I then transfer the file to my laptop, and intend to decrypt it. What do I do? I heard something about "exporting a public key", what does this mean? Do I use the private key on my laptop as well? If I do, how do I put the private key from my desktop onto my laptop? I am just transferring encrypted files between my own personal machines, I am not giving them to anyone else, so do I still need the public key? Thanks.
Encryption is done with the public key. Decryption with the private key. Keys can bei exported to files and imported on another machine. It's possible to upload the public key to a keyserver. listing keys (find your id after "/") gpg --list-keys export private key (replace 12345ABCD with your id) gpg --export-secret-keys --armor 1234ABCD > secret.asc export public key (replace username@email with your email) gpg --output public.pgp --armor --export username@email import private key gpg --import secret.asc
Using GPG keys on multiple devices?
1,479,187,367,000
I have set up an encrypted swap partition following this guide. My /etc/crypttab is set up like this (note the discard option on swap): rootfs UUID=<UUID_root> none luks,discard swap UUID=<UUID_swap> /dev/urandom swap,offset=2048,cipher=aes-xts-plain64,size=512,discard I also have allow_discards=1 in /etc/lvm/lvm.conf. However, when I do a manual trim, the swap doesn't trim: #sudo /sbin/fstrim -av /media/win: 670.4 GiB (719872700416 bytes) trimmed /boot/efi: 221.8 MiB (232525824 bytes) trimmed /boot: 291 MiB (305152000 bytes) trimmed /: 221.7 GiB (237996343296 bytes) trimmed how do I make it trim? On a related note, why is /media/win being trimmed? This is a NTFS partition on a hard drive (not SSD) automounted by Linux so why is TRIM enabled on a hard drive? In fact, when I print lsblk -D, I have /dev/sda (my HDD) showing non-zero values for DISC_GRAN and DISC_MAX, indicating that TRIM is enabled. Why is that?
So apparently because swap is not considered as a normal filesystem, it will not be trimmed when fstrim is run manually. But it appears that the Linux kernel does the trimming for the swap when it is mounted automatically when the underlying device supports the operation. This is referenced in the Fedora project docs: The Linux swap code will issue TRIM commands to TRIM-enabled devices, and there is no option to control this behaviour. One can also see it in the kernel code itself here. So I am not sure how it interacts with encryption but I assume that swap trimming doesn't require any additional configuration (eg in fstab) as long as /etc/crypttab and lvm.conf are set up as in the question above which enables trimming on the LUKS and LVM levels.
fstrim does not trim swap
1,479,187,367,000
I'm writing a bash script with the following snippet: #!/bin/bash # usage '$bash this-script.sh in.pdf out.pdf' stty -echo printf "Password: " read password stty echo echo pdfencrypt "$1" -p "$password" -o "$2" on characters like § ä ö ü it fails with the following message: incompatible character encodings: UTF-8 and ASCII-8BIT Am I encountering a bug of pdfencrypt or is the example not coded correctly? If I use echo "$password" all is going well.
It seems that pdfencrypt requires an 8bit (ISO-8859) encoded password and does not know how to deal with (i.e. convert) UTF-8 passwords. You must use a compatible character encoding when executing pdfencrypt, for encryption and decryption. Plain ASCII ("C") or ISO-8859-n (like "de_DE.latin1" as suggested by Hauke Laging) should work. In my opinion, that just instructs pdfencrypt to take the characters of your password as is (i.e. no conversion necessary), that's all. Just add this line at the top of your script: export LC_ALL=de_DE.latin1 # Or fr_FR, or latin15, or... Any valid locale for your system Or changing this single line may be enough: LC_ALL=de_DE.latin1 pdfencrypt "$1" -p "$password" -o "$2" Do the same for the decoding. If you convert your password with iconv instead of setting LC_ALL, I guess you would have the same issue since pdfencrypt would still believe you are giving it UTF-8 characters when it encounters 8bit ones. Anyway, to make things easier, you probably should stick to the 7bit ASCII character set: space, non-accented letters, digits, basic punctuation, etc. (man 7 ascii) As for the space, you should be aware that reading into a specific variable with (read -r var) removes leading and trailing spaces (actually the characters in the shell variable IFS). That may be annoying for a password. You should use read -r which put the entire line read into the REPLY variable. That would give that code: export LC_ALL=de_DE.latin1 read -r -s -p "Password: " echo pdfencrypt "$1" -p "$REPLY" -o "$2"
Bash script using pdfencrypt fails on certain characters
1,479,187,367,000
I have 2G RAM and 4G swap file. also I have encrypted storage for files. when I boot up my machine there are 100-120M RAM used so plenty of RAM available and swap won't be used (I guess?). If I unlock my storage and later heavily use RAM so I will need my swap file, is it possible that encryption keys will be moved there? I mean this is kind of a silly question, but just to be sure. No hibernation, only sleep; stock kernel without special memory randomizations etc.
It depends on the way that encryption and key storage is done, but you should assume the answer is yes. Stuff are written to the swap space is essentially the data space of user programs. Anything in the linux kernel is going to stay in memory (as you have specified no hibernation), so once information is passed down to the kernel and the user space programs have exited then no keys will be written to swap. However things like FUSE which run in user space can have keys which are written to swap, and if you happened to be zipping or unzipping something when there was a shortage of real memory then keys for that could be written to swap although it would be unlikely.
does non-encrypted swap ever store encryption keys?
1,479,187,367,000
in an attempt to access a truecrypt container, I stumbled about the prerequisite of setting up a loop device... ncoghlan suggested in an earlier answer When you run it as root, losetup -f will automatically create loop devices as needed if there aren't any free ones available. So rather than doing it yourself with mknod, the easiest way to create a new loop device is with sudo losetup -f. That approach will give you a free existing loop device if one exists, or automatically create a new one if needed. My result of "sudo losetup –f" is losetup: –f: failed to use device: No such file or directory Searching for this message+losetup so far does not help. Result of "lsmod |grep loop" is loop 28672 0 uname -r 4.5.7-200.fc23.x86_64
Serge's comment made me do my homework - study the man page in more depth than before. The solution was simply to enter in the shell losetup (without any arguments). Then, afterwards, losetup -f resulted, successfully, in /dev/loop0
how to add a loop device on fedora 23 with losetup?
1,479,187,367,000
I am trying to read a data matrix which I have generated from a private 2096-bit encrypted RSA key. The key was generated using gpg and printed to PDF with the following command: gpg --export-secret-key MY_PRIVATE_KEY_ID | paperkey --output-type raw | dmtxwrite -e 8 -f PDF > ~/key.pdf I then printed key.pdf and scanned it, producing the following jpg file: I now wanted to use the following command to recreate my private key: dmtxread /path/to/image.jpg | paperkey --pubring ~/.gnupg/pubring.gpg > my-regenerated-private-key.gpg However, the command dmtxread prints nothing to stdout and returns 1. I have tried tinkering with the error correction by using -C 10000, reducing the tolerance for rotation by using -q 5, and increasing the canvas size of the image to increase the number of blank pixels to the left and right of the matrix. I also tried with a larger resolution scan (I don't know the DPI, but it was 4MB and the squares were very well defined) and adjusting the contrast tolerance using -t 20 and -t 5, all with the same result (although I had to skip pixels using -S 5 with this large file to get it to finish in < 30 minutes). I tried using --verbose but nothing was printed to stdout (or any diagnostic file as far as I could tell). I have also tried the -D option to produce a diagnostic image. I'm not really sure what to make of the result though: Clearly it's struggling with some of the boundaries, but I'm not sure why or how to make dmtxread more robust. My next step was going to be attempting to decrypt a dummy file using the recovered private key, but obviously I didn't get that far. It's disappointing that this is so difficult; if there is no easy way to do this with the command-line libdmtx tools, maybe there is another tool that can do this for me out of the box? Important: it goes without saying that I would never use this private key for any actual encrypting, now that I've shared it online. You should never share your private key.
Looks like, I managed to get data from your image. I did the following: Open with GIMP Colors -> Threshold Position the slider around center (I don't remember exact value I chose) and click OK Image -> Canvas Size Choose percents Canvas Size: Width: 160 % Canvas Size: Height: 120 % Offset: click on "Center" Click Resize Tools -> Transform Tools -> Rotate tool Angle: -0.50 and click Rotate (it's useful to add a vertical guide before doing so) File -> Export As Choose file name and click Export and then Export (with all defaults) Here is the image I got after all of these steps: Running dmtxread gives an instant result (less than a second): dmtxread --shrink=2 c8wcN1B.jpg > quant.paperkey Size is 1428 bytes, two first octets looks like binary paperkey format. To verify the resulting file, you can download it here.
How do I use dmtxread to read a scanned data matrix?
1,479,187,367,000
I can't find a free/open-source software that password protects my PDFs with AES 256. pdftk just offers 128-bit strength.. In fact I didn't find any other tool that encrypts PDFs. What tool may I use to password protect my PDFs, using AES 256
QPDF says it supports 256bit encryption in it's massive manual. I didn't read it all and have never tried it. It looks like it's worth a shot. http://qpdf.sourceforge.net/
Password protect a PDF file with AES 256
1,479,187,367,000
I have Gentoo Linux installed on a 25.93GB/62.43GB partition /dev/sda4. The other partitions on the disk are 150MB /boot on /dev/sda1 and 56,66GB unused space on other two partitions. I am planning to encrypt the unused space with dm-crypt, format it to ext4 and after migrating my installation onto it, to nuke the old partition. My questions here are: Is this possible at all? Or would it require many tweaks to get the installation running on the encrypted volume /dev/sda2? Is this an efficient way? Taking into consideration my 25.9GB Gentoo, would it be less hassle for me if I just encrypted the whole disk and installed Gentoo(and all the packages) again? Should I use encfs or ecryptfs instead of dm-crypt here? Would they provide equal security? What algorithm should I use to encrypt the partition? My processor does not have AES-NI. What should I use to sync the encrypted partition with the other one? Would something like dcfldd work for that? Edit being written from migrated partition: After deleting the unused partitions and making a new unformatted /dev/sda2, I ran : cryptsetup luksFormat /dev/sda2 cryptsetup luksOpen /dev/sda2 encrypt pv /dev/zero > /dev/mapper/encrypt pv here is used to monitor the progress of writing zeroes, and after this I formatted the encrypted partition to ext4 with mkfs.ext4 /dev/mapper/encrypt. To sync the partitions, I used YoMismo's recommendation rsync after booting the PC from a live USB. It didn't let me in with chroot though, I had to reboot my old partition and chroot from there instead. I ran in this process: mkdir /tmp/old_partition /tmp/new_encrypt mount /dev/sda4 /tmp/old_partition mount /dev/mapper/encrypt /tmp/new_encrypt cd /tmp/new_encrypt rsync -av /tmp/old_partition/* . and after rebooting the old partition /dev/sda4, opening and mounting /dev/sda2 and mounting virtual kernel filesystems: I made an /etc/crypttab with root UUID=<uuid of /dev/sda2> none luks I altered /etc/fstab to tell my root partition is UUID=<uuid of mapper>. I altered /boot/grub/grub.conf : I deleted root=<root> on the end of kernel line, and set a crypted device with crypt_root=UUID=<uuid> root=/dev/mapper/root. I ran genkernel --install --luks initramfs to make new initramfs with luks support. Now I can boot and run it, the only thing left is setting the old partition on fire.
1.- Yes it is possible but you will have to do some tweaking. 2.- You can't encrypt the whole disk, at least boot partition must be unencrypted if you want your system to start (someone has to ask for the decryption password -initrd- and you need it unencrypted). 3.- encfs has some flaws, you can read about them here. I would use dm-crypt for the job. 4.- Can't help, maybe twofish? 5.- I would use a live CD/USB to do the job. I don't know if the space you have left is enought for the data on the other partitions, if it is (the partition is not full) I would: First you need to decide what kind of partition scheme you want. I will assume you only want /, /boot and swap. So /boot doesn't need to be messed with, I will also assume the space left in the unused partition is enough for the data you want to place in the encrypted partition (/ in this case). Start your system with the life CD. Assuming your destination partition is /dev/sdc1 do cryptsetup luksFormat /dev/sdc1 you will be asked for the encryption password. After that open the encrypted partition cryptsetup luksOpen /dev/sdc1 Enc write all zeros to it dd if=/dev/zero of=/dev/mapper/Enc and create the filesystem mkfs.ext4 /dev/mapper/Enc Now mount your partition, copy files and change root to the new partition. mkdir /tmp/O /tmp/D mount /dev/sda4 /tmp/O mount /dev/mapper/Enc /tmp/D cd /tmp/D;rsync -av /tmp/O/* . mount --bind /dev dev mount --bind /proc proc mount --bind /proc/sys sys mount --bind /sys sys chroot /tmp/D mount /dev/sda1 /boot -Use blkid to identify your partitions UUIDs and use that information to modify grub configuration files and your fstab (root partition device should be /dev/mapper/root_crypt). Modify your /etc/crypttab so that the new encrypted partition is referenced there. Create a line like root_crypt UUID=your/encrypted/dev/uuid none luks. grub-update grub-install to where your grub must be and update-initramfs so that the new changes are updated in your initrd. If I haven't missed anything you should now be ready to go unless you are worried about your swap partition, if you are and want to be able to resume from hybernation the you will have to follow the previous steps for encrypting swap partition and mkswap instead mkfs.ext4. You will also need to add the swap partition to the /etc/crypttab modify fstab so that /dev/mapper/name_swap_you_created_in_etc_crypttab is the device for the swap partition and update-initramfs.
Cloning a root partition onto a dm-crypt encrypted one
1,479,187,367,000
I tried everything I was able to find online. Hours of research since yesterday ;( I found no one struggling with the errors I'm facing, except from GitLab (error code -1 instead of -4 I'm getting), Reddit or this mailing list from 2006. I might give unnecessary details, sorry! I have this 5 TB WD drive where I already have dozens of files. Decided to build a small NAS from a Raspberry Pi 4. Problem was I wanted LUKS encryption, with BTRFS as the file system; the drive was at that time a 5 TB one-partition EXT4. I split the drive in 2 partitions (on my main computer) (only 2.3 TB was occupied), creating a LUKS protected BTRFS partition half the drive size: moved everything to the encrypted BTRFS partition, deleting the EXT4 part, growing LUKS, opening the encryption and then grew the BTRFS partition to fill the entire drive, passphrase still worked for LUKS, for a very long time. I thought nothing could happen when I have the LUKS Header Backup. The 5 TB LUKS-BTRFS partition is only protected with a passphrase, no additional slots etc. configured. I was able to unlock the drive and mount it now maybe for 3 weeks without any hiccups and error codes on all my devices (Artix-Linux x86_64, Linuxmint, Debian Aarch64, Parted Magic). The operating system I chose for the Pi 4 was Debian, not Raspbian OS, since it was lacking the Crypto API/Functionality in the kernel I guess needed for serpent-xts-plain64, my drive encryption cipher. The NAS solution I went with was OpenMediaVault. It does not support unlocking LUKS volumes etc. on its own, so I unlocked it via SSH, mounted the device from the Web UI, created an SMB share, was even able to connect and exchange files for a day. The other day when I wake up I notice when I connect to the SMB share there are no files?! A quick lsblk made clear the drive was not mounted, and the encryption was already closed. Mounting it was now impossible, tried many distros/kernels, architectures (aarch64 & amd64), tried mounting using GParted on many systems, KDE's own disk mounter etc. but no, guess I'm stuck. Funny thing is I was able to change the passphrase using cryptsetup luksChangeKey /dev/sdd1, it happily accepted my password, then successfully changed it to something else (as far as I know when I restore the header the old password is valid). Like I said before I have the LUKS header backup available, it's the right file I know it, since I heard restoring the wrong header makes things more complicated. I hope I don't have to reinvent the wheel to decrypt the drive, but if it's necessary, I'll do it :/ As far as I can remember I did luksFormat using this command, it was inside my .zshrc: cryptsetup -v luksFormat /dev/sdd1 --use-random --verify-passphrase --key-size=512 --hash=whirlpool --cipher=serpent-xts-plain64 --pbkdf=argon2id --type luks2 Here is the output of cryptsetup --debug --verbose luksOpen /dev/sdd1 crypt: ❯ sudo cryptsetup --debug --verbose luksOpen /dev/sdd1 crypt [sudo] password for user: # cryptsetup 2.4.2 processing "cryptsetup --debug --verbose luksOpen /dev/sdd1 crypt" # Running command open. # Locking memory. # Installing SIGINT/SIGTERM handler. # Unblocking interruption on signal. # Allocating context for crypt device /dev/sdd1. # Trying to open and read device /dev/sdd1 with direct-io. # Initialising device-mapper backend library. # Trying to load any crypt type from device /dev/sdd1. # Crypto backend (OpenSSL 1.1.1l 24 Aug 2021) initialized in cryptsetup library version 2.4.2. # Detected kernel Linux 5.15.8-zen1-1-zen x86_64. # Loading LUKS2 header (repair disabled). # Acquiring read lock for device /dev/sdd1. # Opening lock resource file /run/cryptsetup/L_8:49 # Verifying lock handle for /dev/sdd1. # Device /dev/sdd1 READ lock taken. # Trying to read primary LUKS2 header at offset 0x0. # Opening locked device /dev/sdd1 # Verifying locked device handle (bdev) # LUKS2 header version 2 of size 16384 bytes, checksum sha256. # Checksum:cd57d8cf3e5d6bd82e34925c05ac3f84114d564dc1535d443d6003847ede9c03 (on-disk) # Checksum:cd57d8cf3e5d6bd82e34925c05ac3f84114d564dc1535d443d6003847ede9c03 (in-memory) # Trying to read secondary LUKS2 header at offset 0x4000. # Reusing open ro fd on device /dev/sdd1 # LUKS2 header version 2 of size 16384 bytes, checksum sha256. # Checksum:1fa2c8c216bef143a6841c7e6d7b1e737b39a832e3e8067ce580b103673c67b6 (on-disk) # Checksum:1fa2c8c216bef143a6841c7e6d7b1e737b39a832e3e8067ce580b103673c67b6 (in-memory) # Device size 5000946236928, offset 16777216. # Device /dev/sdd1 READ lock released. # PBKDF argon2id, time_ms 2000 (iterations 0), max_memory_kb 1048576, parallel_threads 4. # Activating volume crypt using token (any type) -1. # dm version [ opencount flush ] [16384] (*1) # dm versions [ opencount flush ] [16384] (*1) # Detected dm-ioctl version 4.45.0. # Detected dm-crypt version 1.23.0. # Device-mapper backend running with UDEV support enabled. # dm status crypt [ opencount noflush ] [16384] (*1) No usable token is available. # Interactive passphrase entry requested. Enter passphrase for /dev/sdd1: # Activating volume crypt [keyslot -1] using passphrase. # dm versions [ opencount flush ] [16384] (*1) # dm status crypt [ opencount noflush ] [16384] (*1) # Keyslot 0 priority 1 != 2 (required), skipped. # Trying to open LUKS2 keyslot 0. # Running keyslot key derivation. # Reading keyslot area [0x47000]. # Acquiring read lock for device /dev/sdd1. # Opening lock resource file /run/cryptsetup/L_8:49 # Verifying lock handle for /dev/sdd1. # Device /dev/sdd1 READ lock taken. # Reusing open ro fd on device /dev/sdd1 # Device /dev/sdd1 READ lock released. # Verifying key from keyslot 0, digest 0. # Loading key (64 bytes, type logon) in thread keyring. # dm versions [ opencount flush ] [16384] (*1) # dm status crypt [ opencount noflush ] [16384] (*1) # Calculated device size is 9767440351 sectors (RW), offset 32768. # DM-UUID is CRYPT-LUKS2-355457dcd03343349b2121f41f3e0a5c-crypt # Udev cookie 0xd4de97d (semid 4) created # Udev cookie 0xd4de97d (semid 4) incremented to 1 # Udev cookie 0xd4de97d (semid 4) incremented to 2 # Udev cookie 0xd4de97d (semid 4) assigned to CREATE task(0) with flags DISABLE_LIBRARY_FALLBACK (0x20) # dm create crypt CRYPT-LUKS2-355457dcd03343349b2121f41f3e0a5c-crypt [ opencount flush ] [16384] (*1) # dm reload (254:3) [ opencount flush securedata ] [16384] (*1) device-mapper: reload ioctl on crypt (254:3) failed: Invalid argument # Udev cookie 0xd4de97d (semid 4) decremented to 1 # Udev cookie 0xd4de97d (semid 4) incremented to 2 # Udev cookie 0xd4de97d (semid 4) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20) # dm remove crypt [ opencount flush securedata ] [16384] (*1) # Uevent not generated! Calling udev_complete internally to avoid process lock-up. # Udev cookie 0xd4de97d (semid 4) decremented to 1 # dm versions [ opencount flush ] [16384] (*1) # dm status crypt [ opencount noflush ] [16384] (*1) # Udev cookie 0xd4de97d (semid 4) decremented to 0 # Udev cookie 0xd4de97d (semid 4) waiting for zero # Udev cookie 0xd4de97d (semid 4) destroyed # Requesting keyring logon key for revoke and unlink. # Releasing crypt device /dev/sdd1 context. # Releasing device-mapper backend. # Closing read only fd for /dev/sdd1. # Unlocking memory. Command failed with code -4 (wrong device or file specified). The output of fdisk -l: Disk /dev/sdd: 4.55 TiB, 5000947302400 bytes, 9767475200 sectors Disk model: My Passport 2627 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: 2505C284-7B8A-4EAE-90CB-950187A84D57 Device Start End Sectors Size Type /dev/sdd1 2048 9767475166 9767473119 4.5T Linux filesystem The luksDump, arrently needed too; output of cryptsetup luksDump /dev/sdd1: ❯ sudo cryptsetup luksDump /dev/sdd1 LUKS header information Version: 2 Epoch: 5 Metadata area: 16384 [bytes] Keyslots area: 16744448 [bytes] UUID: 355457dc-d033-4334-9b21-21f41f3e0a5c Label: (no label) Subsystem: (no subsystem) Flags: (no flags) Data segments: 0: crypt offset: 16777216 [bytes] length: (whole device) cipher: serpent-xts-plain64 sector: 4096 [bytes] Keyslots: 0: luks2 Key: 512 bits Priority: normal Cipher: serpent-xts-plain64 Cipher key: 512 bits PBKDF: argon2id Time cost: 5 Memory: 1048576 Threads: 4 Salt: 67 4b ad d5 89 b5 64 b7 b7 46 61 0f a4 9f cb be 52 90 11 99 8c c0 fb 81 be 6a d6 ac 58 f5 3c 12 AF stripes: 4000 AF hash: sha256 Area offset:290816 [bytes] Area length:258048 [bytes] Digest ID: 0 Tokens: Digests: 0: pbkdf2 Hash: whirlpool Iterations: 68985 Salt: d7 56 5e 8a d3 7c 7a 86 d3 fc b5 f8 d8 1e 6f 8d b3 fd 04 34 e7 08 ab 9a 33 92 2f 08 96 4b ff 74 Digest: ed 9c d5 5f 0e df b3 f3 5b 71 95 09 9d f0 a8 b5 9c a5 02 cb d0 1f f7 7b 52 d2 24 29 ee b2 7b 3f ed bc bd 1d f8 f7 bb 9f f7 c9 68 9b c9 be 86 66 8b 24 5a 3c b7 b2 3e 93 7e d0 42 7c 7e e1 6d ec S.M.A.R.T. values output using smartctl -a /dev/sdd: ❯ sudo smartctl -a /dev/sdd smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.8-zen1-1-zen] (local build) Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Western Digital Elements / My Passport (USB, AF) Device Model: WDC WD50NDZW-11MR8S1 Serial Number: WD-WXD1E995WRAF LU WWN Device Id: 5 0014ee 211f0443e Firmware Version: 02.01A02 User Capacity: 5,000,947,523,584 bytes [5.00 TB] Sector Sizes: 512 bytes logical, 4096 bytes physical Rotation Rate: 5400 rpm Form Factor: 2.5 inches TRIM Command: Available, deterministic Device is: In smartctl database [for details use: -P show] ATA Version is: ACS-3 (minor revision not indicated) SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s) Local Time is: Fri Dec 17 16:02:40 2021 CET SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x82) Offline data collection activity was completed without error. Auto Offline Data Collection: Enabled. Self-test execution status: ( 249) Self-test routine in progress... 90% of test remaining. Total time to complete Offline data collection: ( 2940) seconds. Offline data collection capabilities: (0x1b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. SMART capabilities: (0x0003) Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01) Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 776) minutes. SCT capabilities: (0x30b5) SCT Status supported. SCT Feature Control supported. SCT Data Table supported. SMART Attributes Data Structure revision number: 16 Vendor Specific SMART Attributes with Thresholds: ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 2 3 Spin_Up_Time 0x0027 253 253 021 Pre-fail Always - 4808 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 825 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0 9 Power_On_Hours 0x0032 098 098 000 Old_age Always - 1577 10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0 11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 321 192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 176 193 Load_Cycle_Count 0x0032 198 198 000 Old_age Always - 6431 194 Temperature_Celsius 0x0022 119 098 000 Old_age Always - 33 196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 0 199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0 200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 1 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t] Selective Self-tests/Logging not supported And here's the DMESG output (simply dmesg, due to character limit couldn't post everything): [ 46.940566] wlan0: associated [ 46.989890] wlan0: Limiting TX power to 23 (23 - 0) dBm as advertised by 5c:49:79:56:19:f7 [ 50.007552] usb 2-6: new SuperSpeed USB device number 2 using xhci_hcd [ 50.020426] usb 2-6: New USB device found, idVendor=1058, idProduct=2627, bcdDevice=40.08 [ 50.020439] usb 2-6: New USB device strings: Mfr=2, Product=3, SerialNumber=1 [ 50.020444] usb 2-6: Product: My Passport 2627 [ 50.020448] usb 2-6: Manufacturer: Western Digital [ 50.020452] usb 2-6: SerialNumber: 575844314539393557524146 [ 50.664550] usb-storage 2-6:1.0: USB Mass Storage device detected [ 50.665002] scsi host4: usb-storage 2-6:1.0 [ 50.665220] usbcore: registered new interface driver usb-storage [ 50.676478] usbcore: registered new interface driver uas [ 51.678278] scsi 4:0:0:0: Direct-Access WD My Passport 2627 4008 PQ: 0 ANSI: 6 [ 51.678667] scsi 4:0:0:1: Enclosure WD SES Device 4008 PQ: 0 ANSI: 6 [ 51.682041] sd 4:0:0:0: [sdd] Spinning up disk... [ 51.703600] scsi 4:0:0:1: Wrong diagnostic page; asked for 1 got 8 [ 51.703603] scsi 4:0:0:1: Failed to get diagnostic page 0x1 [ 51.703605] scsi 4:0:0:1: Failed to bind enclosure -19 [ 52.701886] ......ready [ 57.822064] sd 4:0:0:0: [sdd] Very big device. Trying to use READ CAPACITY(16). [ 57.822250] sd 4:0:0:0: [sdd] 9767475200 512-byte logical blocks: (5.00 TB/4.55 TiB) [ 57.822255] sd 4:0:0:0: [sdd] 4096-byte physical blocks [ 57.822540] sd 4:0:0:0: [sdd] Write Protect is off [ 57.822544] sd 4:0:0:0: [sdd] Mode Sense: 47 00 10 08 [ 57.823041] sd 4:0:0:0: [sdd] No Caching mode page found [ 57.823048] sd 4:0:0:0: [sdd] Assuming drive cache: write through [ 57.983930] sdd: sdd1 [ 57.985534] sd 4:0:0:0: [sdd] Attached SCSI disk [ 57.985680] ses 4:0:0:1: Attached Enclosure device [ 137.355239] nvidia-nvlink: Nvlink Core is being initialized, major device number 507 [ 137.355244] NVRM: The NVIDIA probe routine was not called for 1 device(s). [ 137.356116] NVRM: This can occur when a driver such as: NVRM: nouveau, rivafb, nvidiafb or rivatv NVRM: was loaded and obtained ownership of the NVIDIA device(s). [ 137.356117] NVRM: Try unloading the conflicting kernel module (and/or NVRM: reconfigure your kernel without the conflicting NVRM: driver(s)), then try loading the NVIDIA kernel module NVRM: again. [ 137.356118] NVRM: No NVIDIA devices probed. [ 137.356296] nvidia-nvlink: Unregistered the Nvlink Core, major device number 507 [ 317.920451] device-mapper: table: 254:3: crypt: Device size is not multiple of sector_size feature [ 317.920455] device-mapper: ioctl: error adding target to table [ 2685.464145] raid6: skip pq benchmark and using algorithm avx2x4 [ 2685.464148] raid6: using avx2x2 recovery algorithm [ 2685.468011] xor: automatically using best checksumming function avx [ 2685.528254] Btrfs loaded, crc32c=crc32c-intel, zoned=yes, fsverity=yes [ 2685.564424] JFS: nTxBlock = 8192, nTxLock = 65536 [ 2685.582407] NILFS version 2 loaded [ 2685.676402] SGI XFS with ACLs, security attributes, realtime, scrub, repair, quota, no debug enabled [ 2692.757592] sda: sda1 sda2 sda3 sda4 [ 2694.215474] sdd: sdd1 [ 2768.779512] device-mapper: table: 254:3: crypt: Device size is not multiple of sector_size feature [ 2768.779536] device-mapper: ioctl: error adding target to table [ 3123.484363] usb 2-6: USB disconnect, device number 2 [ 4886.654141] usb 2-6: new SuperSpeed USB device number 3 using xhci_hcd [ 4886.667772] usb 2-6: New USB device found, idVendor=1058, idProduct=2627, bcdDevice=40.08 [ 4886.667776] usb 2-6: New USB device strings: Mfr=2, Product=3, SerialNumber=1 [ 4886.667778] usb 2-6: Product: My Passport 2627 [ 4886.667779] usb 2-6: Manufacturer: Western Digital [ 4886.667780] usb 2-6: SerialNumber: 575844314539393557524146 [ 4886.669555] usb-storage 2-6:1.0: USB Mass Storage device detected [ 4886.669800] scsi host4: usb-storage 2-6:1.0 [ 4887.692812] scsi 4:0:0:0: Direct-Access WD My Passport 2627 4008 PQ: 0 ANSI: 6 [ 4887.693055] scsi 4:0:0:1: Enclosure WD SES Device 4008 PQ: 0 ANSI: 6 [ 4887.694634] ses 4:0:0:1: Attached Enclosure device [ 4887.695784] sd 4:0:0:0: [sdd] Spinning up disk... [ 4887.696087] ses 4:0:0:1: Wrong diagnostic page; asked for 1 got 8 [ 4887.696090] ses 4:0:0:1: Failed to get diagnostic page 0x1 [ 4887.696092] ses 4:0:0:1: Failed to bind enclosure -19 [ 4888.716288] ......ready [ 4893.836679] sd 4:0:0:0: [sdd] Very big device. Trying to use READ CAPACITY(16). [ 4893.836793] sd 4:0:0:0: [sdd] 9767475200 512-byte logical blocks: (5.00 TB/4.55 TiB) [ 4893.836795] sd 4:0:0:0: [sdd] 4096-byte physical blocks [ 4893.837071] sd 4:0:0:0: [sdd] Write Protect is off [ 4893.837072] sd 4:0:0:0: [sdd] Mode Sense: 47 00 10 08 [ 4893.837383] sd 4:0:0:0: [sdd] No Caching mode page found [ 4893.837385] sd 4:0:0:0: [sdd] Assuming drive cache: write through [ 4893.996397] sdd: sdd1 [ 4893.997502] sd 4:0:0:0: [sdd] Attached SCSI disk [ 4951.411265] device-mapper: table: 254:3: crypt: Device size is not multiple of sector_size feature [ 4951.411286] device-mapper: ioctl: error adding target to table
This is a problem with the device size of your partition. Your partition is an odd number of 512-byte sectors large (9767473119 sectors as shown by fdisk). Your LUKS header is set to use 4096-byte sectors (sector: 4096 [bytes] shown by cryptsetup luksDump). So that leaves 7 sectors on the partition that can not be used. Unfortunately, instead of just ignoring the surplus sectors, the device mapper crypt target takes offense, resulting in such error messages: [ 8243.293778] device-mapper: table: 253:49: crypt: Device size is not multiple of sector_size feature (-EINVAL) [ 8243.293781] device-mapper: ioctl: error adding target to table In this case you have to make the partition size 4K aligned, i.e. a multiple of 8 512-byte sectors. You can do that with parted resizepart or any other partition tool of your choice. Just make sure the start sector of the partition does not change.
(Probably) Corrupted LUKS Header, Restoring Header does not work
1,479,187,367,000
How can i encrypt a Linux internal disk, so that it is only accessible with a unique system (preinstalled Debian bullseye), installed on a USB drive? Even if someone has the encryption passphrase and physical access, without the USB drive holding the other system he shouldn't be able to access it. Is there a way to do this?
only to an unique system (preinstalled Debian bullseye) installed on the USB drive even if someone have the encryption passphrase Nope. In cryptography, safety of encryption is always provided by the secrecy of the key, never by not giving someone the decryption software. And in the end, that's what you demand: only the right software can decrypt your drive. However, I think a slight rephrasing of your question allows us to answer this positively. Can I put a decryption key on a USB drive, so that only the person holding that USB drive can decrypt? Yes, that's pretty standard. Simply follow one of the many guides on how to put LUKS keys on an external USB drive, and you're fine. Also note that anything that's stored on a USB drive can be copied – a USB drive is just "stupid" storage. So, if you need something that is uncopyable, then this is not a solution, either. You'll need a uncloneable crypto device (i.e., a device that contains the key itself, and does the decryption internally, never giving out the key itself) which would then allow you to ensure decryption access can never be given away without giving away the card. (unless you allow anyone to change the settings of your drive encryption, because then they could just add another key... but that's another thing.) This then becomes a bit specific to the kind of device you want to use (nitrokey, TPM2 devices, FIDO keys...), but "LUKS + {device name}" would be the terms to search for.
Encrypt main data Linux partition so it's only accessed by unique system
1,479,187,367,000
I had a LUKS partition for which cryptsetup luksDump /dev/mydisk gave (excerpt) Digests: 0: pbkdf2 Hash: sha256 Iterations: 176646 Salt: xx xx ... ... Running cryptsetup reencrypt /dev/mydisk while the container was offline removed the previous digest after it was done (understandably), leaving the following (Iterations has now changed to a much smaller value) Digests: 1: pbkdf2 Hash: sha256 Iterations: 1000 Salt: xx xx ... ... I doubt I selected the first iteration count manually, so I assume it was chosen by benchmark at luksFormat time. After the reencrypt the iteration count is much smaller, and to my poor knowledge so small that it is not recommended. I would have understood if reencrypt re-chose a default, but clearly it didn't even run a benchmark. Since the digest protects the master key, is this a bug in cryptsetup?
This appears to be a bug in cryptsetup. I've filed a report here: https://gitlab.com/cryptsetup/cryptsetup/-/issues/606.
`cryptsetup reencrypt` seems to cripple digest iteration count
1,479,187,367,000
I already did some research on my question (see below), and it's as good as a 'done deal' but I would still like to put forward my problem to this knowledgeable community. Short version of the issue: in partman (the disk partitioner of the Debian installer) the passphrase of a previously dm-crypt/LUKS encrypted volume was changed (or added) by mistake. The data on this volume was not flagged for removal. I cancelled the installation after that point. Later after manually 'decrypting' this volume it was found that only the ‘new’ password could decrypt the volume, but data could not be read (i.e. filesystem and files were not found)... I was wondering if after changing back to the old passphrase I would be able to properly decrypt the volume's contents. Previous research: the above question was submitted to the debian-boot mailing list, and there I received the following (very clear) answer: I don't think the data will be recoverable unless you have a backup of the LUKS header. The way LUKS works is that data is not encrypted with a passphrase directly but with a key that is encrypted to a set of passphrases. If you worked purely through the installer's UI you will have overwritten your LUKS header and hence will be unable to decrypt the data ever again because the key material is lost. The position of the LUKS header on disk is always in the same place. Data erase is really just about overwriting the existing data with zeros, which I understand is pretty confusing. Technically the data is already erased by the fact that the header is overwritten but some people want to be sure and write random data (or in the case of non-encrypted disks zeros) to the disk before deploying the system into production. Alas, I do not have a backup of the LUKS header of this volume. As I said above, the intention was only to mount the previously encrypted volume, and not to change anything (so, to my regret, I didn't take the proper precautions). The question: Is there any way to (re)generate the original LUKS header using the (known) original password against which this volume was encrypted, or is this data permanently lost? Thank you for your consideration and your time.
There is no way to recover whatsoever. (*) With LUKS, the passphrase you use to open the encryption, and the master key actually used for the encryption, are completely unrelated to one another. Basically your passphrase decrypts a completely random key, and this random key is stored in the LUKS header. Losing the LUKS header entirely (or even changing a single bit of key material) renders you unable to obtain the master key used for the volume. This is also why with LUKS, you can have 8 different passwords, and change each of these passwords any time you like, without re-encrypting all data. No matter how often you change the LUKS passphrase, the master key stays the same. Master key recovery is explicitely NOT part of the LUKS concept, quite the opposite actually; LUKS takes many steps to prevent you (or anyone) to recover the master key from a (partly) overwritten LUKS header. The LUKS documentation even advises you to NOT backup the header, as a backup header out of your control means losing the ability to declare an old passphrase invalid. As the old passphrase would still be stored and usable in the old header. (*) The only exception to this rule is if the container is still open. For an active crypt mapping, one might be able to obtain the master key with dmsetup table --showkeys. So if you killed your LUKS header in a running system and realized immediately, you could create a new LUKS header with the known master key. Without the master key you cannot proceed and it's impossible to brute-force the master key, that's the whole point of the encryption in the first place. Well, you could do it given infinite CPU power and/or time, so if you want to leave your descendants with a puzzle, keep a copy of the encrypted data around and pass it on... ;)
The password of previously encrypted volume got changed by the Debian installer
1,479,187,367,000
I want accomplish the following task: On a Ubuntu System with multiple Users accounts and encrypted Home directorys a NFS share should be mounted after login. I want to use systemd user service for this, but can't get it fully working. What's working so far: - manual mount with user rights, configured with sudo - enabling the user service and starting it with systemctl --user start usermount.service After a reboot systemd doesn't even know that this unit exists. I think there is a problem in combination with an encrypted $HOME (ecryptfs in my case), because the service unit and autostart configuration are located in .config/systemd/user/. My assumption is that the systemd user process is started immediatly after login, before decrypting the homedir and hence doesn't see the users configuration. Whats my possibilities to solve this task?
It's a bug in the ecryptfs package configuration. You can use a quick fix: Open /etc/pam.d/common-session and switch the lines session optional pam_systemd.so session optional pam_ecryptfs.so unwrap to session optional pam_ecryptfs.so unwrap session optional pam_systemd.so so that pam_systemd.so is loaded after pam_ecryptfs.so
Use Systemd user services with ecryptfs
1,479,187,367,000
I've recently upgraded our server from CentOS 6 to CentOS 7 and I am having issues getting pdf encryption working on it. On CentOS 6 I installed libgcj and then the pdftk package. I could then encrypt pdfs using /usr/sbin/pdftk pdfName.pdf output pdfEncrypted.pdf owner_pw 123456 user_pw 123654 I know I cannot install pdftk on CentOS 7 because it does not support libgcj but is there an alternate way to achieve what I need?
First Alternative: use qpdf. It's on CentOS 7 base system. # yum install qpdf $ qpdf --encrypt user-password owner-password 40 -- file1.pdf file2.pdf This will take file1.pdf as input, assign user and owner passwords, a key length of 40(valid values are 40, 128, or 256) and export the encrypted data to file2.pdf To "unlock" pdf files: $ qpdf --decrypt --password=password locked.pdf unlocked.pdf You can find here more qpdf encrypt options Second Alternative: There is the possibility to use any general purpouse file encryption tool. You can find a well explained document about some of them here.
CentOS 7 Encrypt a PDF
1,479,187,367,000
Is it possible to encrypt pictures and other files like audio etc with GPG? If yes then how to? If not then why not?.
Yes this is possible. gpg normally handles files as binary and you don't have to do anything special to encrypt pictures or audio. gpg -c yourfile.mp3 for symmetric encryption and gpg -e yourfile.mp3 to encrypt with your (pregenerated) private key.
Encrypt multimedia files with GPG
1,479,187,367,000
For one of my apps I need to enable FIPS for OpenSSL, while simultaneously using software disk encryption. VM #1 I launched a CentOS VM instance which was software encrypted during install. The system booted fine (after entering the boot decryption password). Next, I went through the steps to enable FIPS-OpenSSL and rebooted. The system would not accept my boot decryption password (which was purposely easy to type). VM #2 I set up a second VM with an otherwise identical OS/config without software encryption. I enabled FIPS using the steps above, rebooted, and everything works fine with no problems rebooting. VM #3 I spun up a third CentOS VM instance, also opting not to use system encryption during installation. After install and basic configuration, I encrypted a test volume using luks, then rebooted. I'm prompted for the password and the system then boots normally. Next, I enabled FIPS-OpenSSL, rebooted - and get a plethora of errors where I'd usually see the boot password, and the system does not boot. I booted this VM into single user mode, pulled fips=1 from the kernel line and rebooted. The boot password was accepted this time. ... Why is enabling FIPS for OpenSSL causing the boot passwords to fail?
The problem was that I encrypted the volumes before enabling FIPS. As garethTheRed alluded to in a comment, LUKS used a non FIPS approved algorithm, so when FIPS was enabled things went bonkers. The solution is to Enable FIPS Encrypt volumes In that order. This guide was also useful in solving the problem. It is lengthy with extra explanation so I won't copy paste the full thing here. Here's the jist: A. ENABLE FIPS Check if FIPS is enabled using one of two methods: cat /proc/sys/crypto/fips_enabled 0 = not enabled 1 = enabled openssl md5 /any/file valid hash = not enabled "Error setting digest md5" = enabled (likely) Check if you have prelinking turned on. vi /etc/sysconfig/prelink Change PRELINKING=yes to PRELINKING=no Undo all current prelinking [root@centos64]# prelink -ua Install dracut-fips [root@centos64]# yum install dracut-fips Rebuild your initramfs [root@centos64]# dracut -f Find device path of /boot [root@centos64]# df /boot Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 487652 115447 346605 25% /boot cp /etc/grub.conf /etc/grub.bak Edit /etc/grub.conf Add in the "fips=1" and "boot=/dev/***" lines to the kernel command line Example: kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg_centos6464bittempl-lv_root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_LVM_LV=vg_centos6464bittempl/lv_swap rd_LVM_LV=vg_centos6464bittempl/lv_root rd_NO_MD crashkernel=auto SYSFONT=latarcyrheb-sun16 rd_NO_DM rhgb quiet fips=1 boot=/dev/sda2 Reboot Check if FIPS is enabled (See Step 1 above). B. ENCRYPT VOLUME Are you sure FIPS is enabled? If not, do not proceed - go back to ENABLE FIPS and make sure that part is working before continuing... Get the device path of the logical volume you wish to encrypt. In my example, this is /dev/mapper/vg_mybox-LogVol03 BACK UP ALL DATA ON THIS VOLUME. It will be DESTROYED. umount volume. In my case, umount /db_fips shred -v -n1 /dev/mapper/vg_mybox-LogVol03 Encrypt volume and set passphrase cryptsetup -v --verify-passphrase luksFormat /dev/mapper/vg_mybox-LogVol03 NOTE: a RHEL minimal install may not include cryptsetup by default. Just yum install cryptsetup to get what you need. CentOS 6.7's minimal package set includes cryptsetup. Open the device and alias it to “somename” of your choice (in this case, "db_fips") cryptsetup luksOpen /dev/mapper/vg_mybox-LogVol03 db_fips Verify mapper has the path [root@centos64]# ls /dev/mapper/db_fips At this point, treat /dev/mapper/db_fips as you would any ordinary filesystem or device Create filesystem as you normally would [root@centos64]# mkfs -t ext4 /dev/mapper/db_fips Mount it and verify it [root@centos64]# mount /dev/mapper/db_fips /db_fips [root@centos64]# date >> /db_fips/today.txt ¡¡¡IMPORTANT!!!: Comment out the existing /etc/fstab entry for the target volume, lest you have headaches on reboot. :-) vi /etc/fstab # /dev/mapper/vg_mybox-LogVol03 /some/path ext4 defaults 1,2 Reboot to ensure the steps above are working. get UUID of encrypted volume blkid /dev/mapper/vg_mybox-LogVol03: UUID="2e52ffee-7a02-4c91-b6bf-223b05f90ded" TYPE="crypto_LUKS" Add encrypted volume to /etc/crypttab - so it can be decrypted on boot. You can specify a passfile here, but it is not recommended. Install DRAC in the server if it is to be remotely administered (so you can enter the pass phrase during boot). crypttab man page [root@centos64]# vi /etc/crypttab db_fips UUID="2e52ffee-7a02-4c91-b6bf-223b05f90ded" Reboot to test.
Enabling FIPS on a luks encrypted CentOS system breaks boot password
1,479,187,367,000
I have configured an OpenVPN install. Mode: multiclients 1server. Clients are raspberries. I note how easy it is to steal a rasp, and look in HDD to get key+cert+conf. Copy it on your laptop, and connect the VPN... I'm nooby on it, what would the good way to protect from such a case ? Disk encrypt ? Thank you.
With very few exceptions, if somebody has your hardware in their hands, they can duplicate everything, simply by accessing and copying the whole storage. There's no extra encryption that would help. If you encrypt the disk, the disk encryption key has to be readable somewhere. Disk encryption is useless in your scenario. There is hardware that can't be easily duplicated, such as smartcards. However, even if you connect a smartcard reader to the RPi, the thief can just steal the card with the Pi. You can protect against someone stealing (or borrowing) the Pi or the SD card if the SD card is encrypted and the key is not available to the thief. This means that you or someone you trust would have to type in a password, or insert an SD card that contains the encryption key for a USB key, in order for the Pi to boot. This isn't perfect protection: someone could make a dump of the RAM — but since the RAM is soldered on a Pi, that's a relatively difficult hardware attacks. If you're on an RPi budget, you probably don't need that level of resistance. There are hardware platforms with an integrated tamper-resistant key storage: TPM on PC platforms, ARM system-on-chips with TrustZone and hardware root of trust (TrustZone alone as a CPU feature isn't enough). The hardware cost is an order of magnitude more than a Raspberry Pi. Note that even these systems wouldn't prevent theft; they would only prevent the thief from duplicating the client device. Another route to protection is physical protection: put the device in a locked box that is securely fastened to a building fixture. If you can't prevent adversaries from physically accessing the client device, then you can't prevent them from stealing your keys. All you can do is attempt to detect the theft. For example, if multiple clients turn up with the same client certificate, there's definitely something wrong (but you face a hard decision if you can't tell which one is the legitimate one: allow access to all, or deny access to the legitimate one).
OpenVPN : protect your clients key/cert/conf from being stolen?
1,479,187,367,000
I'm learning about encryption and decryption on linux and php. So I have three questions about openssl and how it generates password hashes. 1- So say I generated a password with the linux command openssl passwd My first observation is that every time I generate a hash, it's different! Why is that? Is it because of salt? That's my first question. 2- Now my second question is about testing this password. Say I want to test the correctness of this password and get a binary answer, whether it's correct or not. How do I do that with openssl? If my question doesn't make sense, then how is openssl passwd useful? 3- If I encrypt my password with a hash using openssl passwd, and every time there's a random salt added to it, how does openssl decrypt it (or any other program for that matter)? Thank you.
openssl crypt you password with an algorithm and a salt. If you do not provided a salt an random is choosen. the salt is given in the resulting hash. for instance openssl passwd -1 foo $1$pyuddMjp$3.deTnHdrVVVLoh5zkQ0B. where 1 is proticol (md5 here) pyuddMjp is salt If I want to verif you know passwd (i.e. foo), I need to compare resulting hash, using passwd option with salt. with x=bar openssl passwd -1 -salt pyuddMjp $x $1$pyuddMjp$kNkQHWoF8WVh7Oxvae5YX1 with x=foo openssl passwd -1 -salt pyuddMjp $x $1$pyuddMjp$3.deTnHdrVVVLoh5zkQ0B.
How does openssl decrypt a password
1,479,187,367,000
How can I automount an EncFS unit at login/start my session? I use Fedora 20 and KDE. Please don't mention apps like Cryptkeeper and so. I would rather console solutions.
You can use pam_mount. Read step 5 in this mini tutorial that walks you through it. Please note that there is a security issue with this.
Automount EncFS unit
1,479,187,367,000
I need encrypt whole disk on Debian 7.5, (it will be work as server) but I need enter encryption password via SSH. So I need encrypt whole disk except primary system features as ssh server, because for example I need remotely restart this server. Do you know about any effective options?
First step would be to decide what needs to be encrypted and what not. There is no need to encrypt a standard debian server release, its not like it contains any secrets. Create at least two partitions, one for the normal stuff and one for the sensitive stuff. Then you install the complete server as normal, without any sensitive data (on the normal partition). Disable autostarting for all services that need the sensitive data. Setup the encryption stuff, see if manual mounting and manual starting the servers work. Finally, to reduce work needed, create a script to automate that. For example name it /root/decrypt-and-start.sh #!/bin/sh # mount the encrypted filesystem # this will ask for a password mount-encrypted-file-system # start the services service apache2 start service foo start You can no start this script with ssh root@server ./decrypt-and-start.sh, you will need to provide the root password (or use passwordless authentication) and the disk password.
Encrypt my disk but allowing to enter the password with SSH
1,479,187,367,000
I have about twenty files symmetrically encrypted with CAST5. I have a single passphrase that is meant to work with all of the files and I wish to confirm that it does. I wrote a script to perform a check a check on each file. read pass for file in *.gpg ; do if ! gpg --batch --passphrase "$pass" -d "$file" &>/dev/null ; then echo "Passphrase invalid for '$file'." fi done My method of checking to see if the passphrase is valid for each file requires the decryption of the entire file, which is extremely slow. Is there a quicker way to do what I am attempting to do?
Unfortunately there is no way of asking gpg-agent whether a key is passphrase protected. But you need not check the files but each key once only. Thus you should first check which keys are involved. There is no need to check the same key twice (by using it to decrypt two files). I have to admit that though I consider myself a GnuPG expert I don't get this done in an elegant way thus I have just asked on the GnuPG mailing list. I will edit this answer when I have the info from there. Edit 1 Took the masters a few minutes only... The solution is: --list-only gpg --status-fd 1 --list-only --list-packets file.gpg | awk '$2 == "ENC_TO" {print "0x" $3; }' gives you the key ID(s). Before you try to decrypt a file you check whether one of its recipient keys is in the list of keys which you have already checked. The slow operation is the asymmetric decryption. Nonetheless you should sort the files by size and start with the smallest. The above command gives you the subkey (if it was encrypted for a subkey). If you want to be really good then you don't compare the subkeys but the respective main keys. In every normal installation the main key and the subkeys have the same passphrase (with GnuPG you even have to fight to give them different passphrases).
Checking if a passphrase is able to decrypt symmetrically encrypted files
1,479,187,367,000
I have a T61 with C2D T7300 CPU/4 GByte RAM. I has SL 6.3 on it, and I ticked the encrypt VG during install. If I start a "normal" windows xp on it, its ~slow.. so.. I need a little performance boost :) Loud thinking/QUESTION: kcryptd could take ~20% (!) of CPU, but encryption is needed.. soo I was thinking that how can I encrypt only the home directory of that 1 user (and AES256 isn't needed, just a very-very light encryption, so that a burglar can't access the data on the notebook, I'm not defending against the "CIA" :D or at least a lighter encryption) UPDATE: I'm voting for: aes-ecb-null -s 128 So before the install I have to manually create the partitions. AFAIK using this and not using the default could really increase performance. UPDATE2: https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-LUKS_Disk_Encryption.html - so looks like they are using 512 bits aes-xts-plain64.
There are three main storage encryption possibilities under Linux. Ordered from lowest level to highest level, from fastest to slowest, from least flexible to most flexible: Dm-crypt to encrypt a whole filesystem (or more generally any storage device). You get the best performance, but you have to decide to use it when you organize your storage partitions, and there's a key per partition. Ecryptfs to encrypt a user's home directory. Each user has their own key. The encryption is performed in the kernel, but the encryption is at the file level rather than at the block level which slows things down. Encfs to encrypt a few files. This can be set up by an ordinary user, as it only requires the administrator to provide FUSE. You can easily have multiple filesystems with different keys. It's slower than the other two. Given your constraints, dm-crypt is clearly the right choice. You can get better performance by encrypting only the files that need to be encrypted, and not the operating system. If you haven't really started to use your new system, it'll be simpler to reinstall, but you can also work on your existing system by booting from a live CD such as SystemRescueCD. Make a system partition and a separate /home partition, or even a separate /encrypted partition if you don't want the whole home directory to be encrypted but only some selected files. Make a dmcrypt volume for the one filesystem that you want to encrypt. There might be a little to gain by choosing the fastest cipher. AES-128 instead of AES-256 should give you a very slight performance increase at no cost to security. Pick CBC rather than XTS for the cipher mode, since you don't need integrity: cryptsetup luksCreate -c aes-cbc-sha256 -s 128. You can even choose aes-cbc-plain as the cipher: it's insecure, but only if the attacker can plant chosen files on your system, which doesn't matter for your use case; I don't know if there's any gain in performance though. The choice of hash (-h) only influences the time it takes to verify your passphrase when you mount the disk, so don't skimp on it.
Fast encryption for home directory with Scientific Linux (ala' RedHat)
1,332,339,921,000
Suppose Bob got a message from Alice encrypted with his public key and signed with her private key. Now he wants to prove to Charlie that he got a message from her with this exact content. The message was created via gpg --sign --encrypt. My idea was that he could decrypt the message and save it with its signature somewhere but I could find no way to achieve this. But since GPG signs the message and then encrypts it afterwards this should at least theoretically be possible. Now how can he do this or do you have any other ideas how Bob can proof the message authenticity to Charlie? Restrictions: Giving Charlie Bobs private key is (obviously) not an option. Communication is only possible via email. Alice cannot be contacted any more so resending the message or Charlie and Alice communicating with each other is not possible. Bob has to work with what he already has.
This was pretty hard to find. It is not in local man gpg. The command: gpg -vi --unwrap msg1.gpg (-v means verbose, -i is interactive, does not overwrite files.) Caveat: You might(?) need to decompress the output sometimes. Documentation: https://gnupg.org/documentation/manuals/gnupg.pdf --unwrap This command is similar to ‘--decrypt’ with the difference that the output is not the usual plaintext but the original message with the encryption layer removed. Thus the output will be an OpenPGP data structure which often means a signed OpenPGP message. Note that this option may or may not remove a compression layer which is often found beneath the encryption layer. Testing (on Ubuntu, fresh in August 2023). ### Alice(=testS) signed a message and encrypted it ### using Bobs(=test) public key. -r means --recipient [0] $ echo A message to be signed a sent > message [0] $ gpg -u testS -r test --sign --encrypt message ## Alice sent message.gpg to Bob [0] $ gpg -vi --unwrap message.gpg # --output ... gpg: WARNING: no command supplied. Trying to guess what you mean ... gpg: public key is 3DF37C69945F312D gpg: using subkey 3DF37C69945F312D instead of primary key 96B43A891E43F2F4 gpg: using subkey 3DF37C69945F312D instead of primary key 96B43A891E43F2F4 gpg: encrypted with 3072-bit RSA key, ID 3DF37C69945F312D, created 2023-08-29 "TEST TE <[email protected]>" gpg: AES256 encrypted data File 'message' exists. Overwrite? (y/N) n Enter new filename: message-only-singed.gpg ## Bob sends "unwrapped" (=deciphered) file message-only-signed.php ## to Charlie [0] $ gpg -d message-only-singed.gpg A message to be signed a sent <---- The message gpg: Signature made Tue 29 Aug 2023 22:55:11 CEST gpg: using RSA key 6646102A06EC96A49AE8828FCDF0F02D337492DD gpg: issuer "[email protected]" gpg: Good signature from "tests <[email protected]>" [ultimate] <---- the sig ### Charlie sees that Alice=testS signed the message (The last command can be used with --output file.)
Convert encrypted and signed to just signed PGP message
1,332,339,921,000
I need to encrypt some data using aes-256-ecb since a backend code expects it as a configuration. I'm able to encrypt using a key which is derived from a passphrase using: openssl enc -p -aes-256-ecb -nosalt -pbkdf2 -base64 -in data-plain.txt -out data-encrypted.txt | sed 's/key=//g' This encrypts using derived key and outputs the key in console. However, I couldn't find how to do it with a generated key, something like: Generate a 256-bit key using: openssl rand -base64 32 > key.data Then use this key during encryption, with something like: openssl enc -p -aes-256-ecb -key=key.data -nosalt -pbkdf2 -base64 -in data-plain.txt -out data-encrypted.txt Is this possible?
You have to specify the key in hex using -K. Note that you also need to specify the IV with -iv for some ciphers and modes of operation. You will also need to add -nopad for ECB decryption if you are decrypting a raw AES block (i.e. no padding is used). Be aware that ECB is highly insecure if used to encrypt more than one block.
openssl encrypt by specifying AES 256 key instead of passphrase
1,332,339,921,000
I can encrypt my /dev/sdb4 with cryptsetup this way sudo apt-get install cryptsetup sudo umount /dev/sdb4 sudo cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb4 sudo cryptsetup luksOpen /dev/sdb4 sec sudo mkfs.ext3 /dev/mapper/sec sudo mount /dev/mapper/sec /mnt People can't get the content in /dev/sdb4 without the key created.The partition can be shown in gui: How can hide the encrypted partition in gui?
You can do this with a udev rule. e.g. I use the following file (/etc/udev/rules.d/95-hide-block-devices.rules) to hide my mdadm devices and ZFS zvols from various GUI file selector dialogs: KERNEL=="[mz]d*", ENV{UDISKS_IGNORE}="1", ENV{UDISKS_PRESENTATION_HIDE}="1" I only have one mdadm device these days (for /boot), and I definitely don't want that to be accidentally unmounted by clicking on the Eject icon. I also have a lot of VMs on my desktop machine, all using ZFS zvols for storage - so this hides dozens of unwanted block device entries from pcmanfm (I use xfce4, not gnome) and from my file open & save dialogs. In your case, you could use: KERNEL=="sdb4", ENV{UDISKS_IGNORE}="1", ENV{UDISKS_PRESENTATION_HIDE}="1" You probably also want to hide the related device mapper block device, so add: KERNEL=="dm-xxx", ENV{UDISKS_IGNORE}="1", ENV{UDISKS_PRESENTATION_HIDE}="1" (where dm-xxx is the device mapper name in /dev for your encrypted device. adjust to suit your system) Remember to run udevadm trigger after creating or editing udev rules.
How can hide the encrypted partition in gui?
1,332,339,921,000
Are there any backup/cloning/recovery tools that can pull files from LUKS-encrypted disks while dropping free blocks? Something that runs from within the unlocked system and hot-transfers the files, or maybe runs from a bootable USB flash drive, prompts the encryption key, and unlocks the disk?
The fact that your disk is encrypted is largely irrelevant. Whatever you use will need the encrypted disk to be opened (cryptsetup luksOpen ...) before operation. I'll also draw your attention to e2image which may copy more filesystem meta data. It only works with ext2,3,4 file systems. Besides e2image, your only real option is to look at tools which copy file trees rather than blocks. For backups, I use rsync copy files. Besides files, what else does your system need? Partition definitions will not be backed up with rsync. Partitions sizes can be listed with with fdisk -l <disk> eg: fdisk -l /dev/sda and stored this in a file somewhere for safe keeping. To boot up, you system will probably use UUIDs to know what file system mount's where. These can be listed with blkid (sudo blkid). If your system is using EFI (rather than legacy boot) then you need to also copy the contents of your EFI partition.
Backup tool for pulling files out of encrypted disks?
1,332,339,921,000
I have several drives encrypted with VeraCrypt and I wanted to be able to mount them all to automount when I insert a drive containing their keyfiles. This way I only have to decrypt the flash drive that contains the keyfiles and only type in one password. I created an automation program in Nim to handle this: https://github.com/TomAshley303/veramount My usage is to have my veramount program run on each boot. The problem is that in order to mount a VeraCrypt volume you need to supply a sudo password, so I added VeraCrypt to /etc/sudoers. However it simply didn't work. Each time my veramount program runs, VeraCrypt isn't given sudo access. If I run veramount from the command line after authenticating to sudo, for instance after running something like sudo ls, it works fine. I thought maybe this was because the calling program (veramount) needed to be added to sudoers but that didn't work either. I wound up with the following: %veracrypt ALL=(ALL:ALL) NOPASSWD: /usr/bin/veracrypt %veramount ALL=(ALL:ALL) NOPASSWD: /home/user/Code/nim/mountkey/veramount Is there something wrong with my sudoers rule? Something must be wrong. Edit: I realize that in my Nim code I don't use the sudo command to run VeraCrypt. This is because I want my drives to be mounted with permissions for my user account and because when you use VeraCrypt to mount a drive, it automatically prompts you with a popup dialog for your sudo password anyway.
%veracrypt ALL=(ALL:ALL) NOPASSWD: /usr/bin/veracrypt %veramount ALL=(ALL:ALL) NOPASSWD:/home/user/Code/nim/mountkey/veramount Instead of %veracrypt and %veramount, there should be the name of the user, which should have sudo permission to execute the script. Something like this: myusername ALL = (root) NOPASSWD: /path/to/my/program Also make sure this is the last line. Save and exit.
/etc/sudoers rule is not being obeyed
1,332,339,921,000
Let's say I use LUKS for all my system except for /boot and I have my /home/user directory encrypted as well. In the context of the security of my user account (Which is more than less isolated from root) should I create another encrypted container to store my key files for the purpose of quick mounting of encrypted drives? At first I wanted to have my drives auto-mounted when I login to my user account but that seems less secure. Would it be better to encrypt a thumb drive and store my keys on it so that I have to decrypt/mount the thumb drive first? I see this sort of thing suggested here and here but that then begs the question: If I'm decrypting a drive containing keyfiles in the context of my user account, is it anymore secure than if I'd stored them somewhere in /home/user?
Storing a keyfile in the same location as the encrypted volume is useless. Encryption is only useful if the decryption key is stored separately from the encrypted volume: in your head, on a removable device (USB key, smartcard, …), etc. (There is one way in which encryption is still useful with the key stored in the same location: quick wipe. You can effectively wipe the data on an encrypted volume by wiping the key, you don't need to wipe the whole volume. But that's marginal.) To use full-disk encryption, you need to input the decryption key at boot time, one way or another. So you either need to type a passphrase, or insert a removable device containing the keyfile. Encryption is only useful against someone who steals the disk (with or without the rest of the computer). It doesn't protect against software that's running on the computer: the operating system's isolation and access control mechanisms do that. Once you've booted the system, the protection against stealing the computer (including temporarily “stealing” the computer by typing at the keyboard while you're away) is screen locking. If this is a single-user system then there are not many scenarios where additional encryption beyond the full-disk encryption is useful. Either the attacker has access to your account and they can access all your files, or the attacker doesn't have access to your account and they can't access anything except by putting the disk in their computer, which leaves them with an encrypted disk and (assuming the key didn't get stolen with the disk) no way to decrypt it. There can be an advantage in having a second layer of encryption if there are files that you consider to be especially confidential and you don't use them often. If that's the case then encrypt them with a different passphrase. Then, if your computer is infected by malware, then the malware won't be able to access all your most confidential files, only the ones that for which you entered the decryption key before you noticed the malware. Another advantage in a second layer of encryption is to protect against relatively sophisticated attackers who steal the computer while it's still running and extract the key from RAM. You can protect against this by configuring your computer to unmount decrypted volumes while you aren't in front of the computer. This requires a second layer of encryption (unless you skip full disk encryption and only encrypt your personal files) because the system files have to remain accessible (the decryption software and the interface to read the key have to be available). I believe that iOS and Android are heading towards such a setup, if they haven't reached this point yet, but I don't know of an easy way to set this up under Linux. Regarding the aspect of storing the keyfiles themselves on an encrypted container, that only makes sense if the encrypted container is protected by a passphrase rather than another keyfile, and it's only useful if the container is a removable drive. Protecting the removable drive with a passphrase means that if someone steals the drive but can't guess your passphrase, they won't be able to decrypt your data. But once again, if the keyfiles are on the same media as the data, then there's no benefit to having the keyfiles in the first place.
Where Should I Store Encryption Keyfiles?
1,332,339,921,000
I'm using a NAS (Buffalo LinkStation Pro with SSH access, if that matters) which runs Linux (2.6.31.8 #1 Fri Jun 8 11:07:30 JST 2012 armv5tel GNU/Linux, with smbd --version = Version 3.0.30-1.4.osstech), while all clients run Windows 7. Currently, the shares are on a xfs partition. How can samba be modified such that the share behaves like an NTFS share to the clients, i.e. allowing for encryption? Or do I need to reformat the partition as an NTFS drive (or more likely, use a loop-mounted NTFS file)?
A Samba share can never behave as a NTFS share, only as a SMB/CIFS share. If you want encryption then you will need to use a per-file/directory tool, or implement it in the server instead.
Which filesystem to use when a samba share should allow for NTFS encryption?
1,332,339,921,000
Using Fedora/Ubuntu, how can I do it?
You need patched kernel, losetup and mount. The package is usually called util-linux, you can get the patches from here. If you don't want to boot from a loop-aes device it's really simple: # Write 65 lines of random data to keyfile.txt This will be used as a key for # the data on the disk and your password will be as a key for this file. # You will need this file and the password to access your data. # Keep them safe. gpg -c --cipher-algo aes256 --digest-algo sha512 < keyfile.txt > keyfile.gpg rm keyfile.txt # Better if you never write this to disk in the first place. losetup -e aes256 -H sha512 -K keyfile.gpg /dev/loopX /dev/sdXX mke2fs -t ext4 /dev/loopX mount /dev/loopX /mnt # To mount it later mount -o loop=/dev/loopX,encryption=aes256,hash=sha512,gpgkey=keyfile.gpg /dev/sdXX /mnt If you want to encrypt the root partition then I recommend reading the extensive documentation. Basically you will need to create an initramfs and store it on an unencrypted boot partition. You can store the keyfile.gpg (and the boot partition if you decide to encrypt the root) on a removable USB device.
How can I encrypt a device with loop-aes under Linux?
1,332,339,921,000
Is it possible to create a single-user USB installation (with persistence) of Ubuntu Linux such that the entire USB stick is encrypted and requires a passphrase at boot time? Is there an online tutorial for this?
It should be straightforward to make a persistent installation directly on a USB stick, as if it was an internal disk. Plug in your Ubuntu installation media (I recommend not putting it on the same stick, so that the two are bootable separately), your USB stick, and point the installer to the stick. The server installer (alternate CD) supports creating and installing to an encrypted partition (with dm-crypt).
USB Ubuntu with whole-disk encryption
1,332,339,921,000
I was wondering if it's possible to automatically decrypt and mount a ZFS pool and its datasets at boot. Currently, I have to unlock the pool manually by using the command # zfs load-key -a and then run # zfs mount -a. It might also be worth mentioning that the "key", at the moment, is a passphrase (maybe it would be better to convert it to a keyfile and store it somewhere on the system?). I'm running Ubuntu Server 23.04
I found out how to do this myself. First of all, after you've loaded the keys using # zfs load-key -L file:///path/to/keyfile <pool>, the key will stay loaded unless you explicitly unload it using # zfs unload-key. In case you want to try to automatically load the key anyway, below'ss a quick systemd service I've written, but be warned: the service will fail unless you unload the keys before rebooting. # /etc/systemd/system/zfs-load-key.service [Unit] Description=Load encryption keys DefaultDependencies=no Before=zfs-mount.service After=zfs-import.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/zfs load-key -L file:///etc/zfs/zpool.key <pool-name> [Install] WantedBy=zfs-mount.service There are a couple of ways to automatically mount the pool(s) at boot: Option #1: Using zfs-mount.service sudo zpool set cachefile=/etc/zfs/zpool.cache <pool-name> sudo systemctl enable --now zfs-import-cache.service sudo systemctl enable --now zfs.target sudo systemctl enable --now zfs-import.target sudo systemctl enable --now zfs-mount.service Option #2: Using zfs-mount-generator sudo mkdir -p /etc/zfs/zfs-list.cache sudo systemctl enable --now zfs.target sudo systemctl enable --now zfs-zed.service sudo touch /etc/zfs/zfs-list.cache/<pool-name> cat /etc/zfs/zfs-list.cache/<pool-name> # if the file is empty, check that zfs-zed.service is running; if it is, run the command below sudo zfs set canmount=off <pool-name> cat /etc/zfs/zfs-list.cache/<pool-name> # if the file has been updated, run the command below sudo zfs set canmount=on <pool-name> # A file needs to be (manually) created in `/etc/zfs/zfs-list.cache` for each ZFS pool in your system and ensure the pools are imported by enabling `zfs-import-cache.service` and `zfs-import.target`.
How can I automatically unlock and mount a ZFS pool at boot?
1,332,339,921,000
I apparently messed up today. I have to resize an encrypted root partition to make room for a windows dual boot. I followed instructions from the arch wiki since it seemed to match my needs even though I am using debian. At some point I had to use pvmove because after shrinking the root partition, the free space was between my root and swap partition. I thought it all went well, but I apparently messed up my sector/bytes/stuff calculations at some point. Right now the machine is booted from a live debian usb key and this is the output of what I think are the relevant shell commands. user@debian:~$ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 2.3G 1 loop /usr/lib/live/mount/rootfs/filesystem.s sda 8:0 0 3.6T 0 disk sdb 8:16 1 114.6G 0 disk sdc 8:32 1 28.9G 0 disk ├─sdc1 8:33 1 2.5G 0 part /usr/lib/live/mount/medium └─sdc2 8:34 1 2.6M 0 part nvme0n1 259:0 0 3.6T 0 disk ├─nvme0n1p1 259:1 0 512M 0 part ├─nvme0n1p2 259:2 0 488M 0 part └─nvme0n1p3 259:3 0 3.5T 0 part └─cryptdisk 253:0 0 3.5T 0 crypt # this is where the "fun" happens So, I managed to free 100G for windows, looks good so far. But... user@debian:~$ sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptdisk Enter passphrase for /dev/nvme0n1p3: user@debian:~$ sudo vgchange -a y licorne-vg WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized? WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes. device-mapper: reload ioctl on (253:2) failed: Invalid argument 1 logical volume(s) in volume group "licorne-vg" now active user@debian:~$ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 2.3G 1 loop /usr/lib/live/mount/rootfs/filesystem.squashfs sda 8:0 0 3.6T 0 disk sdb 8:16 1 114.6G 0 disk sdc 8:32 1 28.9G 0 disk ├─sdc1 8:33 1 2.5G 0 part /usr/lib/live/mount/medium └─sdc2 8:34 1 2.6M 0 part nvme0n1 259:0 0 3.6T 0 disk ├─nvme0n1p1 259:1 0 512M 0 part ├─nvme0n1p2 259:2 0 488M 0 part └─nvme0n1p3 259:3 0 3.5T 0 part └─cryptdisk 253:0 0 3.5T 0 crypt └─licorne--vg-root 253:1 0 3.5T 0 lvm Panic intensifies... 253:2 was my encrypted swap partition which was part of this cryptdisk. user@debian:~$ sudo pvdisplay /dev/mapper/cryptdisk WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized? WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes. --- Physical volume --- PV Name /dev/mapper/cryptdisk VG Name licorne-vg PV Size 3.54 TiB / not usable 0 Allocatable yes (but full) PE Size 4.00 MiB Total PE 928007 Free PE 0 Allocated PE 928007 PV UUID x5fLwB-qnhM-qc4x-y28f-FdDM-pFGI-9I6SYh user@debian:~$ sudo lvs WARNING: Device /dev/mapper/cryptdisk has size of 7602233344 sectors which is smaller than corresponding PV size of 7602235392 sectors. Was device resized? WARNING: One or more devices used as PVs in VG licorne-vg have changed sizes. LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root licorne-vg -wi-a----- <3.54t swap_1 licorne-vg -wi------- 976.00m user@debian:~$ sudo dmesg | grep device-mapper [ 99.652244] device-mapper: uevent: version 1.0.3 [ 99.652317] device-mapper: ioctl: 4.43.0-ioctl (2020-10-01) initialised: [email protected] [ 100.537014] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344 [ 100.537016] device-mapper: core: Cannot calculate initial queue limits [ 100.537027] device-mapper: ioctl: unable to set up device queue for new table. [ 1451.395603] device-mapper: table: 253:2: dm-0 too small for target: start=7600236544, len=1998848, dev_size=7602233344 [ 1451.395605] device-mapper: core: Cannot calculate initial queue limits [ 1451.395956] device-mapper: ioctl: unable to set up device queue for new table. Is this LVM/LUKS setup in a recoverable state? I think that licorne--vg-root and only the swap partition suffered, which is OK, right? What steps should I follow here to fix things? Thanks for your help.
Thanks to @frostchutz I got this fixed by using parted to extend /dev/nvme0n1p3 by 2048 sectors.
How can I fix LVM PV size after a botched encrypted partition shrinking
1,332,339,921,000
I am working on encrypting a stream with aespipe to a logfile, and it makes sense to append to the same file every time I run it, so I wanted to do something like my_stream | aespipe -K my_key >> aes_logfile I have already taken into account that aespipe writes out blocks of 512 bytes, and I made sure to pad my stream so that it always outputs data in increments of those sizes. I almost have my plan working, except that aespipe mangles the first byte of every 512 byte increment after the first file. For example, the following file that_file (the line ends with ~) is 512 bytes. Hey StackOverflow, here is a ~ small example. The lines are ~ 32 characters long (including ~ the trailing \n) and with ~ aespipe you can encrypt this ~ file with ~ ~ cat this_file | aespipe -K \ ~ your_key_with_one_line.gpg \ ~ > enc_file ~ ~ then you can concatenate onto ~ the encrypted file again with ~ >> and get a new file. ~ Note that this file is 512 B. ~ So it is the right block size ~ This is the output of the following: # First go cat that_file | aespipe -K my_key.gpg > aes_logfile # Second go cat that_file | aespipe -K my_key.gpg >> aes_logfile # Try decrypting cat aes_logfile | aespipe -d -K my_key.gpg annotated output: Hey StackOverflow, here is a ~ small example. The lines are ~ 32 characters long (including ~ the trailing \n) and with ~ aespipe you can encrypt this ~ file with ~ ~ cat this_file | aespipe -K \ ~ your_key_with_one_line \ ~ > enc_file ~ ~ then you can concatenate onto ~ the encrypted file again with ~ >> and get a new file. ~ Note that this file is 512 B. ~ So it is the right block size ~ Iey StackOverflow, here is a ~ # <-- H became I! small example. The lines are ~ 32 characters long (including ~ the trailing \n) and with ~ aespipe you can encrypt this ~ file with ~ ~ cat this_file | aespipe -K \ ~ your_key_with_one_line \ ~ > enc_file ~ ~ then you can concatenate onto ~ the encrypted file again with ~ >> and get a new file. ~ Note that this file is 512 B. ~ So it is the right block size ~ This happens every 512 bytes, and I have no idea why. Is there anything that can be done to fix this? (aespipe version 2.4d)
Well, I can reproduce it. # dd count=1 if=/dev/zero | aespipe > aes_zero Password: Error: Password must be at least 20 characters. # dd count=1 if=/dev/zero | aespipe >> aes_zero Password: Error: Password must be at least 20 characters. # cat aes_zero | aespipe -d | hexdump -C Password: Error: Password must be at least 20 characters. 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ^^ 00000210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400 Ciphertext: # hexdump -C aes_zero 00000000 b3 a3 72 9b 18 5b 6b 73 e5 48 88 d1 8b 66 e3 10 |..r..[ks.H...f..| 00000010 a8 a0 ee d3 7e 08 91 86 6b f7 30 b2 ea 6a 58 0b |....~...k.0..jX.| [...] 000001e0 d9 2a 60 22 c9 4a 37 5c 47 21 65 0a bb f3 a8 7d |.*`".J7\G!e....}| 000001f0 50 9f ef 38 9a c1 95 2b ff 85 c7 16 cc 90 a7 18 |P..8...+........| 00000200 b3 a3 72 9b 18 5b 6b 73 e5 48 88 d1 8b 66 e3 10 |..r..[ks.H...f..| 00000210 a8 a0 ee d3 7e 08 91 86 6b f7 30 b2 ea 6a 58 0b |....~...k.0..jX.| [...] 000003e0 d9 2a 60 22 c9 4a 37 5c 47 21 65 0a bb f3 a8 7d |.*`".J7\G!e....}| 000003f0 50 9f ef 38 9a c1 95 2b ff 85 c7 16 cc 90 a7 18 |P..8...+........| 00000400 You can already tell that this is bad crypto, since the ciphertext repeats which is not supposed to happen at all. Also nothing wrong with the ciphertext itself: # dd count=1 if=aes_zero | md5sum 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.00136312 s, 376 kB/s f328ce6ff88545bc803b033561cbdffd - # dd count=1 skip=1 if=aes_zero | md5sum 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.00148213 s, 345 kB/s f328ce6ff88545bc803b033561cbdffd - So this is identical and the wrong byte appears during decryption. Actually what I naively expected is not off by one byte but random data following the first 512 bytes. Since for most usual encryption schemes, the IV should be different for each sector so as to avoid repeating ciphertext, and the result should be completely different. Encrypting 1024 bytes in one go: # dd count=2 if=/dev/zero | aespipe >> aes_zero2 Password: Error: Password must be at least 20 characters. # hexdump -C aes_zero2 00000000 b3 a3 72 9b 18 5b 6b 73 e5 48 88 d1 8b 66 e3 10 |..r..[ks.H...f..| 00000010 a8 a0 ee d3 7e 08 91 86 6b f7 30 b2 ea 6a 58 0b |....~...k.0..jX.| ... 000001e0 d9 2a 60 22 c9 4a 37 5c 47 21 65 0a bb f3 a8 7d |.*`".J7\G!e....}| 000001f0 50 9f ef 38 9a c1 95 2b ff 85 c7 16 cc 90 a7 18 |P..8...+........| 00000200 60 89 3e 37 87 1c 37 31 1a 11 50 b6 99 50 d3 74 |`.>7..71..P..P.t| 00000210 af a9 a2 30 3d e6 72 5f f3 96 6d 3b 9e 5b 33 6f |...0=.r_..m;.[3o| ... 000003e0 3f d3 2e 9a 18 ad 7a c9 5a ee 04 99 28 e6 af 3f |?.....z.Z...(..?| 000003f0 a3 a9 71 be 1a 56 35 01 06 b9 57 dd fc 42 7c 47 |..q..V5...W..B|G| As you can see, ciphertext repeats not at all. So your concatenating simply produces the wrong ciphertext (IV set incorrectly) and getting that much intact text back regardless is a big suprise and not good cryptography. You're not supposed to be able to move ciphertext around to a different offset and get a sensible result back (with only the first few bytes affected by wrong IV). Try to reproduce the same with LUKS (aes-xts-plain64): # truncate -s 1024 luks_zero # losetup --find --show luks_zero /dev/loop9 # cryptsetup open --type plain --cipher aes-xts-plain64 /dev/loop9 luks_zero Enter passphrase for /dev/loop9: Error: Password must be at least 20 characters. # dd if=/dev/zero of=/dev/mapper/luks_zero dd: writing to '/dev/mapper/luks_zero': No space left on device 3+0 records in 2+0 records out 1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000719156 s, 1.4 MB/s This is zeroes, encrypted by LUKS. Duplicate ciphertext: # sync # dd count=1 seek=1 if=/dev/loop9 of=/dev/loop9 # hexdump -C /dev/loop9 00000000 1c 18 b1 e6 57 9c a1 60 8c 98 f0 d3 59 8b 97 0c |....W..`....Y...| 00000010 bc fc 8a 62 68 52 51 f1 51 49 bf 21 2e f5 bc 84 |...bhRQ.QI.!....| [...] 000001e0 4a e0 ef eb 8f 09 18 a8 73 95 0b 2c 59 01 69 1b |J.......s..,Y.i.| 000001f0 92 71 e6 0d dd 3b 71 b5 22 f4 34 1c e1 4a 95 71 |.q...;q.".4..J.q| 00000200 1c 18 b1 e6 57 9c a1 60 8c 98 f0 d3 59 8b 97 0c |....W..`....Y...| 00000210 bc fc 8a 62 68 52 51 f1 51 49 bf 21 2e f5 bc 84 |...bhRQ.QI.!....| [...] 000003e0 4a e0 ef eb 8f 09 18 a8 73 95 0b 2c 59 01 69 1b |J.......s..,Y.i.| 000003f0 92 71 e6 0d dd 3b 71 b5 22 f4 34 1c e1 4a 95 71 |.q...;q.".4..J.q| 00000400 Ciphertext is perfectly duplicated. Decryption result: # hexdump -C /dev/mapper/luks_zero 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 b7 6c 5c 84 3d 7d dc 58 fc d5 ee 7f 20 c0 d5 09 |.l\.=}.X.... ...| 00000210 a8 78 f8 d8 38 4b 6a 24 bb b1 d2 65 b8 5c 2b ac |.x..8Kj$...e.\+.| [...] 000003e0 08 31 74 f4 59 92 3b 7f 0f fa b9 36 2e de 53 e2 |.1t.Y.;....6..S.| 000003f0 24 83 01 53 6e 56 dc a5 3a 3f 1b 4e d5 0a fd a9 |$..SnV..:?.N....| 00000400 512 Bytes of zero followed by complete garbage. That doesn't prove the crypto is good but it's not obviously lousy as the one you got from aespipe. Now, since this is due to bad IV you can simply make sure to encrypt with correct IV in the first place. aespipe has the -O sectornumber flag for that: -O sectornumber Set IV offset in 512 byte units. Default is zero. Data is encrypted in 512 byte CBC chains and each 512 byte chain starts with IV whose computation depends on offset within the data. This option can be used to start encryption or decryption in middle of some existing encrypted disk image. New way of encrypting and concatenating things: # dd count=1 if=/dev/zero | aespipe -O 0 > aes_zero Password: Error: Password must be at least 20 characters. # dd count=1 if=/dev/zero | aespipe -O 1 >> aes_zero Password: Error: Password must be at least 20 characters. See that it matches the one we encrypted in one go: # md5sum aes_zero aes_zero2 3b0479e04a46a3d268dc4252e066d2b5 aes_zero 3b0479e04a46a3d268dc4252e066d2b5 aes_zero2 Verify decryption result is correct now: # cat aes_zero | aespipe -d | hexdump -C Password: Error: Password must be at least 20 characters. 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400 The DNA matches, the timing works, everything checks out, ... well, it does not improve the crypto itself but fixes the immediate issue, maybe it's good enough for the purpose. Dynamically deriving the correct -O sectornumber value from file size is left as an exercise to the reader.
concatenating aespipe files: wrong byte every 512 bytes after first file
1,332,339,921,000
This question is about the optional encryption of user data with the live Linux distribution KNOPPIX v6.2 (2009-11-18), which as I understand is based on Debian. I do not use this old version anymore, but I am trying to retrieve years-old data from the persisted data file knoppix-data.aes created by KNOPPIX v6.2 in the startup prompts. The file is one byte less than 4 GiB. I was hoping someone who knows about Linux encryption standards going back to the late 2000s might be able to provide some information about this file (as I shall explain below). I'm not very familiar with Linux encryption standards, and am a bit overwhelmed by the myriad of terms I see (like "LUKS", "dm-crypt", etc.) -- I'm not certain which, if any, applies to my situation with late 2000s Knoppix. Obviously the ".aes" in the file name indicates AES encryption. At first I suspected I was typing the password incorrectly, but now I wonder if there might be another issue that would render my attempts to correctly type the password futile. I will explain: When I view the file with a hex editor, it's surprising to see that the beginning of the file is a cleartext list of file names and hashes, e.g.: f4374a5897aafd09a2439f6c3f4a961d5cc7c1a1 *autorun.bat eaf953dce8de1442e4e32769260e22435a70f3bc *autorun.inf (etc.) (also included are hashes for many files that obviously relate to Knoppix, such as KNOPPIX/knoppix-logo-small.png, to give one example) The beginning bytes seems to match exactly with the plaintext file /mnt-system/KNOPPIX/sha1sums (on the USB drive where Knoppix is installed, so it's apparently part of the Knoppix installation). After that there are expanses of null bytes (00), and then random gibberish. I was expecting the entire thing would be random gibberish; in the context of AES encryption, the cleartext at the beginning of the ".aes" file would seem to be incongruous. As a test, I powered off, renamed the original AES file, and then rebooted and created another knoppix-data.aes that is 256 MiB, with password "123456789". This one does not contain the cleartext at the beginning, and I am able to write to it (and successfully decrypt it on subsequent boots). But I don't know about this opaque file format (or where the documentation for it is), other than it (presumably) involves an AES algorithm (but I have no details about mode of operation, key derivation, header, etc.). In particular, is it normal to have this cleartext stuff (sha hashes and file names) at the beginning of the file, as some kind of header, perhaps? Or would it indicate that the file has somehow become corrupted (such as by being concatenated with the sha1sums file in some bizarre circumstances)? If the answer is that it's normal for the cleartext sha1 sums to be there, does that mean I need to provide an offset to losetup to move past the cleartext? I'm currently using echo "mypassword" | losetup -p 0 -e aes -k 256 /dev/loop2 knoppix-data.aes mount /dev/loop2 /media/mydir/ to avoid having to reboot every time I want to attempt decryption. This works for the 256 MiB test version of knoppix-data.aes, with password "123456789" and with no cleartext at the beginning, but not for the original 4 GiB file that has the cleartext hashes (it complains about the file system not being specified, which presumably means that it cannot be automatically determined, which presumably means that the decryption produced gibberish rather than the desired data, possibly because the cleartext is not supposed to be there, or because losetup needs an offset to move past it).
Well, corruption seems like the only possible explanation (someone did a cp file /dev/loopX or similar). loop aes does not have metadata so the file should be random throughout (perhaps except for sectors that were never written to, i.e. "free space"). You don't want an odd offset, you need to use the original offset to have any chance of decrypting the parts that were not overwritten. Unfortunately loop aes is not a very consistent standard, see also loop-aes observations from the cryptsetup FAQ. The only case where a changed offset would be applicable is if the file was actually produced by cat cleartextfile aesfile > newaesfile or similar, i.e. if the data were whole but moved to a later offset in the file. But then you'd have an odd file size, not 4G sharp, so you can rule that one out. it complains about the file system not being specified Well, that's expected if the filesystem headers got overwritten - you have to look at the decrypted raw data to find out if there's anything non-gibberish in it. Whatever is cleartext in the aes file will be gibberish in the decrypted view, no matter which password you choose...
Does the presence of cleartext sha1 sums in knoppix-data.aes indicate corruption?
1,332,339,921,000
I'm working on dm-crypt utilizing cryptsetup. I'm interested to understand if it's using a fixed block dimension to encrypt files. I explain it better: I created a LUKS envelop, formatted it with luksFormat, then open and mounted in file system. Then I normally write files in that encrypted folder. I want to understand if I write 8 Kb file there is the possibility that dm-crypt encrypt it in blocks of fixed dimensions and in case there is a way to modify this block dimension?? |-----------------------------------------------| |+ 8Kb +| |-----------------------------------------------| | b1 | b2 | b3 | | | | bn | | | | | | | | | --------------------------------------------------
Are you talking about the blocksize used by the cipher? Cryptsetup uses block ciphers, often with a 16 byte blocksize. Changing the cipher might change the blocksize, see /proc/crypto for available ciphers & details, and man cryptsetup. Cryptsetup has a fixed blocksize, 512 bytes, here's a little from it's FAQ: 2.18 Is there a concern with 4k Sectors? Not from dm-crypt itself. Encryption will be done in 512B blocks, but if the partition and filesystem are aligned correctly and the filesystem uses multiples of 4kiB as block size, the dm-crypt layer will just process 8 x 512B = 4096B at a time with negligible overhead. LUKS does place data at an offset, which is 2MiB per default and will not break alignment. See also Item 6.12 of this FAQ for more details. Note that if your partition or filesystem is misaligned, dm-crypt can make the effect worse though. Also mentioned in 5.16: There is a potential security issue with XTS mode and large blocks. LUKS and dm-crypt always use 512B blocks and the issue does not apply. Might also be interested in this closed cryptsetup issue (#150) Add dm-crypt support for larger encryption sector (block) size: Comment by chriv... on 2013-11-07 11:32:05: I would be very interested in this. It turns out, there are many embedded-type systems with on-board crypto accelerators, that fail to perform adequately when given small blocks to work with. Examples include mv_cesa, which is found in so many home NASes these days (all the orion/kirkwood boards, at least. This includes most of Synology and QNaps offerings) Milan Broz @mbroz commented 5 months ago - Owner: The sector size option is in kernel 4.12 but will be supported only (optionally) in LUKS2.
dm-crypt / cryptsetup which block encryption dimension use
1,490,733,977,000
I'd like to build a Debian Live system based on sid with an encrypted root filesystem. It's quite easy to install a Debian system with a rootfs encrypted with dm-crypt/LUKS, so I suppose it's also doable on a live system. In Debian Live 2.x, lh_config used to support an --encryption parameter which would do just that, but it's been removed in version 3.x, presumably because loop-aes has more-or-less been dropped from more recent version of Debian. I'm looking to do this because I'm booting the live system from PXE (with the help the fetch boot parameter) and would like to make sure it's used only by IT staff, as it contains sensitive information. As an alternative, I've looked into using an encrypted persistence image, which seems to be better supported in Debian Live, but couldn't figure out how I could load it remotely instead of being looked for on local media.
I've sent a patch for version 4.x to the Debian Live developpers as a starting point to implement this.
Debian Live 3.x with encrypted root filesystem
1,490,733,977,000
I'm attempting to remove a number of ciphers from my openSSH installation: ssh -Q cipher 3des-cbc blowfish-cbc cast128-cbc arcfour arcfour128 arcfour256 aes128-cbc aes192-cbc aes256-cbc [email protected] aes128-ctr aes192-ctr aes256-ctr [email protected] [email protected] [email protected] I've attempted to remove, for example blowfish-cbc, by editing the configuration file: vi /etc/ssh/sshd_config And adding either the line: Ciphers -blowfish-cbc or Ciphers [comma separated list of all other ciphers except for blowfish-cbc] However, upon system reboot or unloading/loading of SSH, blowfish-cbc is still reported in ssh -Q ciphers. What am I doing wrong? OS X Version: 10.11.6
sshd_config only affects the ssh daemon, while you're testing the ssh client, which uses ssh_config.
OS X ignoring sshd_config
1,490,733,977,000
I have a weird ask. I have a tar achive, archive.tar.gz, filled with plaintext files. That archive is then gpg encrypted into archive.tgz.gpg. In total, archive.tgz.gpg is < 100KB. Now, I want to make archive.tgz.gpg look like a linux binary, and have it be un-obfuscated using mostly unix standard utilities. I'm aware that it's (very likely) not going to work as a binary executable, and that's ok. But at a cursory glance, it should roughly appear as a corrupted binary executable. The furthest I've gotten is trying to modify the header using cat and dd so that file doesn't correctly return the file type, but I haven't gotten very far in finding much information about doing this online. If someone would be able to help point me in the right direction, I'd greatly appreciate it. Thanks!
You can totally embed the payload into a working executable. echo "I am your encrypted message." > message.txt gpg2 --symmetric message.txt ld -r -b binary -o message.o message.txt.gpg gcc -o unsuspicious unsuspicious.c message.o With unsuspicious.c containing any program: #include <stdio.h> int main(int argc, char** argv) { printf("Hi. I am a totally unsuspicious executable.\n"); } With this technique, the payload will end up in the .data section of the binary. To retrieve it, extract the entire data section: objcopy --dump-section .data=data.bin unsuspicious Some other data is preceeding my 104 bytes of payload. I used nm unsuspicious to determine the exact difference between __data_start and _binary_message_txt_gpg_start, in my case 16 bytes. Knowing this, I can retrieve the payload: dd if=data.bin skip=16 bs=1 count=104 of=message.txt.gpg Whether this is a valid implementation for your goal depends on whether you consider nm, objcopy and dd "standard utilities". Of course, you can always add some logic to the program itself so it just prints the payload if asked nicely.
Make GPG encrypted file look like binary executable
1,490,733,977,000
So I've seen many many posts on how to do the conversion with private key; but does anyone one know how I can do this with just only public key? As I'm trying to convert someone else's public key. Or is this something not possible and I need to ask them to generate one themselves?
If you are just looking to convert a public key, not create a certificate then you only need the public key. ssh-keygen -f id_rsa.pub -e -m pem > id_rsa.pub.pem Will read a public key file id_rsa.pub (containing just your friend's public key) and convert it to pem format. The private key would be needed for something like a self signed certificate (in x509 format) because it's the private key that generates the signature.
Can openssl convert SSH public key to a PEM file without private key?
1,490,733,977,000
I know that I can create a GPG keypair from the CentOS 7 terminal by typing gpg --gen-key and following the resulting steps, but how can I make sure that the resulting public key is self-signed? And how can I send the resulting key via email to a remote computer? I know that I can send an email with an attachment using mailx from the command line as follows: echo "this is the body of the email" | mailx -s"Subject" -a public.key [email protected] But the mailx code snipped assumes that the key is available in a file. In reality, the key is locked up in a keyring and needs other syntax in order for it to be accessed. EDIT I am following @HaukeLaging's advice. I have created a new key, but when I type gpg --list-sigs in the command line, I get the following results: /home/username/.gnupg/pubring.gpg ----------------------------------------- pub 4096R/CODE1 2015-02-04 uid User Name <[email protected]> sig 3 CODE1 2015-02-04 User Name <[email protected]> sub 4096R/CODE2 2015-02-04 sig CODE1 2015-02-04 User Name <[email protected]> Which of these key codes is the public key? And Which is the private key? I do not want to accidentally send the private key to anyone. EDIT#2 As per @HaukeLaging's response to EDIT#1, I tried: `sudo gpg --armor --export CODE1 >/home/username/my_public_cert.asc` but the result is an empty file when I then cd /home/username/ and ls -al. Also, gpg --list-packets /home/username/my_public_cert.asc resulted in gpg: processing message failed: Unknown system error Why is gpg --armor --export CODE1 >/home/username/my_public_cert.asc producing an empty file?
First, find the public key you want to export: gpg --list-public-keys Look at the line marked 'pub'; it displays your public key type and number. For instance: pub 1024D/5000280F 2009-07-10 Use the number to do your export: gpg --armor --export 5000280F > klaatu_pubkey.asc Check to make sure it worked: cat klaatu_pubkey.asc As long as it's not empty, you can send that file to your friends. Since the PGP model is based on a web of trust, it is beneficial to get your public key out there into the world so people can start using it. The easiest way to do that is to post it to a key server: gpg --export send-keys 5000280F --keyserver keys.fedoraproject.org Key-servers mirror one another periodically, so your key will propagate and people who receive signed emails from you can just download/import your pub key from the network of key servers.
creating and sending a self-signed public key using GnuPG in CentOS 7
1,490,733,977,000
I'm going to create encrypted lvm on my disk. As a encryption mechanism I choose dmcrypt with LUKS. Here's my question - should I overwrite (for security reasons) whole disk before creating encrypted container, or overwrite already encrypted container (there is some information at cryptsetup FAQ - step 6) or both? Does it matter?
If you do not overwrite the previous contents of the disk, any old information will remain in a trivially (software-only) readable form until it happens to be overwritten, which may be a very long time (bordering on forever). If you do overwrite the previous contents of the disk with zeroes before creating the LUKS data structures on-disk, you have largely removed the possibility of reading old data off the disk (it will be a decidedly non-trivial task using software, but might be possible with specialized hardware, a lot of time and a lot of money) but since the odds of any length of data encrypting to all zeroes is negligible, it is trivially easy to determine which parts of the disk hold actual encrypted data. Hence, a determined adversary can focus on the parts of the disk that actually hold data. If you do overwrite the previous contents of the disk with random data before creating the LUKS data structures on-disk, it will be very difficult to determine which areas of the disk holds actual data and which are simply noise, because they will look largely the same. (Without the key, properly encrypted data is indistinguishable from noise.) An attacker may be able to tell that there is a LUKS data container there because of its inherent data structures, but won't be able to tell which parts of the disk are worth attacking cryptographically. If you do fill the encrypted container with zeroes or random data, anything outside that container will still hold the previous data and be susceptible to the same risks as if you didn't do any overwriting of the disk content. With an encrypted container covering the whole disk, this will be a trivial but still nonzero amount of data. Which one of these is appropriate for you is a matter of risk analysis. Any overwrite takes a good while, but the difference in time between overwriting with zeroes and with pseudo-random data is rather small in comparison. Overwriting the disk has an additional benefit: it exercises the entire physical area of the disk, allowing the drive to identify and relocate damaged areas before anything important gets written to it. Since with encrypted (like compressed) data any single bit errors are going to multiply rapidly, the potential benefit from this is non-trivial and comes at a relatively modest cost. I overwrite the entire disk with random data as a matter of course before initializing it as a LUKS device, because I feel the benefits of such an approach outweigh the cost (with the cost being primarily time to first use of the new drive). If you overwrite the entire disk (using something like dd if=/dev/urandom of=/dev/sdb bs=1M -- warning, do not run that command unless you know exactly why you are doing so!), then you don't need to do a separate overwrite of the encrypted LUKS partition, because it's already random-looking enough. And of course, the obligatory XKCD reference: drug him and hit him with this $5 wrench until he tells us the password. But I'm sure you are aware that even full disk encryption is no panacea.
Overwriting disk before encryption
1,490,733,977,000
I am trying to mount a bitlocker encrypted drive with dislocker. Here are the exact commands I ran: sudo dislocker -r -V /dev/sdb7 -u -- /media/bitlocker sudo mount -r -o loop /media/bitlocker/dislocker-file /media/mount After running the last one, I get mount: /media/mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error. Edit: I checked the dislocker-file, and the OEM-ID field below has spaces after NTFS. Is it the culprit, and how do I fix it regardless? $ sudo file -s /media/bitlocker/dislocker-file | tr , '\n' /media/bitlocker/dislocker-file: DOS/MBR boot sector code offset 0x52+2 OEM-ID "NTFS " sectors/cluster 8 Media descriptor 0xf8 sectors/track 63 heads 255 hidden sectors 63 dos < 4.0 BootSector (0x80) FAT (1Y bit by descriptor); NTFS sectors/track 63 sectors 560084065 $MFT start cluster 786432 $MFTMirror start cluster 7680070 bytes/RecordSegment 2^(-1*246) clusters/index block 1 serial number 0feb8f9cbb8f98307; contains bootstrap NTLDR
I see that you are missing specify the filesystem of your device (this case NTFS). Let's try with this mounting command: sudo mount -t ntfs-3g -r -o loop /media/bitlocker/dislocker-file /media/mount Here are some sample parameters for tag -t: exFAT: exFAT-fuse NTFS: ntfs-3g
Cannot mount dislocker-file loop: wrong fs type, bad option, bad superblock
1,490,733,977,000
If I encrypt (dm crypt, LUKS) my whole system, how many RAM should I provide ? I've understood that LUKS volume is mounted RAM, ... If my system is 10 Gb, should I have something like RAM 12 Go ?
You have misunderstood. The LUKS data is stored on disc and encrypted/decrypted a block at a time as necessary (of course there is some caching going on). I don't know the minimum size, but I operated a 32Gb LUKS encrypted ReiserFS partition from a 1 GB memory PC. A whole disc shouldn't make any difference from using LUKS on a partition.
LUKS encryption full disk, how many RAM?
1,490,733,977,000
I have to prepare a computer to give away, and I do not know who is going to use it. The computer has Debian installed, and the HDD is entirely encrypted. All users have their storage on the server. I have been believing that if it meet some conditions below this will safe huge works for all computer departments: Anyone can power on/off computer as they wish Only permitted users can use installed applications Permitted Users can not view any configuration files, modify, store data and copy the HDD content even when they remove it to another computer The HDD only works with the given computer. When it stolen or tap, it is automatic destroy all data inside. How can I go about doing that?
It's not really possible. You simply can not prevent someone powering on/off a computer, or indeed them doing whatever they want with it once they have hands on access. I've done something similar, for a server. It uses full disk encryption and produces its key based on hardware data such as CPU type, Mac Address, amount of memory installed, etc. If someone just took the disk out and placed it in another machine, a different key would be produced and as such the system would not reveal its data. It's meant as a protection when someone exchanges the disk in the data center and puts it in someone else's server without wiping it first. Still you have to be aware that it does not really protect against someone who wants to mess with your stuff.
Secure the content of a hard disk
1,490,733,977,000
I have a USB flash drive with Full Disk Encryption using LUKS. I plugged in the drive and mounted it as such using the following: cryptsetup luksOpen /dev/sdb flash mount /dev/mapper/flash /mnt/flash If I physically remove my flash drive I can still access it's contents at /mnt/flash. Why is this? I see it as a security risk as I want my flash drive contents to become inaccessible as soon as the drive is physically removed. What can I do to make this happen? It needs to be something I can do to the drive as I use this on other computers and I don't want to have to change them all to make the drive secure.
If you ran a program / script from the USB itself, you should be able to figure out what LUKS map/name and device it's on (or just tell the script the device or mapped name if you know it) and watch for when the device "disappears" when it's removed. Then unmount it. I'm pretty sure that unplugging a USB will cause the device (/dev/sdXn) to disappear, but in case it doesn't you'd have to watch dmesg or look in the syslog, or find it somewhere in /sys perhaps. Here's a proof-of-concept bash script that looks like it should work, but I don't have any LUKS partitions on usb's to test with, so I'm not sure if umount might need options like --lazy or --force. map=$( df --output=source $PWD |tail -n1 ) device=$( sudo cryptsetup status "$map" | grep -o "device:.*"|cut -d' ' -f 3 ) while [ -b "$device" ] do sleep 30 done echo "Device $device is missing, unmounting" sudo umount -v "$map" If it's run from inside the mounted LUKS container, $PWD should find the LUKS name it's mapped on, and then the device, and if the device stops being a block special file then unmount the mapped device. PS If the device was mounted rw (writeable) the filesystem can be corrupted by suddenly unplugging it. FAT seems especially vulnerable, while a journaling filesystem should be more robust. If it's mounted ro (read-only) at least you could avoid that problem, mount accepts -o ro and cryptsetup accepts --readonly (both probably aren't necessary)
LUKS partition still accessible after removing drive physically
1,490,733,977,000
I'm having issues unlocking an encrypted disk over ssh using dropbear. I've followed this guide to set it up, but I just end up getting Permission denied (publickey) error I copied the public key from my machine ~/.ssh/id_rsa.pub to the server /etc/dropbear-initramfs/authorized_keys and updated with update-initramfs -u -k all The config of /etc/dropbear-initramfs/config currently have this content: DROPBEAR_OPTIONS="-I 120 -c /bin/cryptroot-unlock" I also tested with the config from the article DROPBEAR_OPTIONS="-RFEsjk -c /bin/cryptroot-unlock" Using SSH, I've tried specifying the identity key (-i), tried with no username, server machine username, my machine username etc... I simply cannot get past the Permission denied error.
During writing the question, I figured it out, and might as well tell anyone else wondering. When using ssh, you need to specify root as the user: ssh [email protected]
dropbear-initramfs Permission denied (publickey)
1,490,733,977,000
I often use gpg command to encrypt files like so gpg -c file which produces a file.gpg. I would like to get rid of the command line aspect and have a right click button in my Nautilus. I tried installing the Seahorse extension for Nautilus but it doesn't work very well and I would like to keep the simplicity of my above command. How should I do?
As far as I know there are two simple ways to add entries to the Nautilus context menu : Nautilus scripts nautilus-actions package, which, depending on your distribution might be depreciated. I'm running on Debian Bullseye/sid where nautilus-actions is not available so I will present the way using Nautilus script. To learn more about this Nautilus functionality you can spend a little time on the Ubuntu side of StackExchange, guys talk a lot about Nautilus scripts down there. Basically, this feature allows you to add context menu entries to Bash (or Python for example) scripts located in your ~/.local/share/nautilus/scripts/ directory. Using two scripts What I propose is to implement two scripts: one to encrypt, one to decrypt. Your contextual menu will look as follows when right-clicking on a file : Encrypt script The encrypt script would simply be #!/usr/bin/env bash # Encrypt # gpg-encrypt Nautilus script gpg -c --no-symkey-cache "$1" && rm -f "$1" where the first Bash argument $1 is the file path selected by Nautilus when right-clicking. The --no-symkey-cache prevents gpg from keeping the passphrase in cache. By default the passphrase is stored for a certain amount of time after encrypting and decrypting a file, I personally don't like this feature so I use this option. I also added && rm -f "$1" in order to remove the original file after encryption, you can remove that if you don't want it. Decrypt script The decrypt script would be #!/usr/bin/env bash # Decrypt # gpg-decrypt Nautilus script ext=`echo "$1" | grep [.]gpg` if [ "$ext" != "" ]; then gpg --batch --yes --no-symkey-cache "$1" else zenity --error --text "The selected file is not crypted." fi Let me explain what the script does. It uses a variable ext which is empty when the selected file is not a .gpg file and which is not empty if the selected file is a .gpg file. If the selected file is an encrypted .gpg file, the script will use the gpg command to decrypt it. I passed the options --batch --yes in order to overwrite if the output file already exists. For example decryption of file.gpg will overwrite file if it exists. If you don't want to overwrite, I suggest you use the output gpg's option and zenity --file-selection to specify the decrypted file name. If the selected file is not an encrypted .gpg file, the script will use zenity --error to pop-up an error window. This script test whether the file is encrypted by looking through the extension. A better way to do that would be to check the MIME type of the selected file. The MIME type of the encrypted file can be found using $ > file $ file -b --mime-type file.gpg application/octet-stream Since application/octet-stream refers to a general binary file and not necessary to an encrypted file I don't think that this approach would be better than checking on the file extension. On the other hand I know that Nautilus maps my gpg-encrypted files to the application/pgp-encrypted MIME type. Maybe someone knows how to get this MIME type from a .gpg file using something else than the file command, in that case it would be relevant. Using two files If you don't want to use two right-click menu entries you can use one single script : #!/usr/bin/env bash # Encrypt-Decrypt # gpg-encrypt/decrypt Nautilus script ext=`echo "$1" | grep [.]gpg` if [ "$ext" != "" ]; then gpg --batch --yes --no-symkey-cache "$1" else gpg -c --no-symkey-cache "$1" && rm -f "$1" fi This script will decrypt if the selected file is a .gpg file and encrypt if the selected file is every else. Decrypt with double click in Nautilus Additionally you can allow Nautilus to decrypt encrypted .gpg when double-clicking by adding the following desktop entry into your ~/.local/share/applications/ directory. # Decrypt.desktop [Desktop Entry] Name=GPG Decrypt Terminal=false Type=Application MimeType=application/pgp-encrypted; Exec=gpg --batch --yes --no-symkey-cache %F NoDisplay=true If no other application is used by default, double-clicking in Nautilus will now decrypt the file. Seahorse might be selected as default application if you're using default GNOME, in that case you have to select GPG Decrypt in Open With Other Application Menu. Installation This little Bash script will install everything in the right location for you : chmod +x 'Encrypt' 'Decrypt' # script files must be executable! cp Encrypt Decrypt ~/.local/share/nautilus/scripts/ cp Decrypt.desktop ~/.local/share/applications/ update-desktop-database ~/.local/share/applications/ nautilus -q nautilus Demo PS: Tested on GNOME 3.34.2 and gpg 2.2.17 (you can check that with $ gpg --version).
GPG encryption in Nautilus right click menu
1,490,733,977,000
At work, we have an iMac (running OS X) that shares a partitioned hard drive over the network. I'd like to back up to my partition from my Linux machine. I've attempted connecting via cifs, then attempted to back up using backintime onto an encfs-encrypted volume. This throws up a whole lot of errors, and I assume that it is because cifs is unhappy with hard-links and other unix wizardry. I seem to remember on OS X that you can create monolithic, encrypted disk images that you could then mount as a "local" (and hence file-system–agnostic) volume. This seems ideal. Hence, I'd connect to the remote volume via cifs, then "locally" mount the encrypted volume as ext4. Is there an equivalent in Linux?
Would be strange of that was possible in OS X but not with Linux. It's exactly the same: cd /cifs/dir dd if=/dev/zero of=encbackup.img bs=1M count=100 # 100 MiB size sudo losetup /dev/loop0 /cifs/dir/encbackup.img # assuming loop0 is free sudo cryptsetup luksFormat /dev/loop0 sudo cryptsetup luksOpen /dev/loop0 cr_cifs_backup sudo mke2fs -j /dev/mapper/cr_cifs_backup sudo mount -t ext3 /dev/mapper/cr_cifs_backup /where/ever It probably makes sense from a performance perspective to create a second (much smaller) image locally (non-encrypted) and put the journal there (see man tune2fs, options -j and -J). Edit 1: The existing device is mounted the same way (just leaving out dd, luksFormat, and mke2fs): sudo losetup /dev/loop0 /cifs/dir/encbackup.img # assuming loop0 is free sudo cryptsetup luksOpen /dev/loop0 cr_cifs_backup sudo mount -t ext3 /dev/mapper/cr_cifs_backup /where/ever Edit 2: To unmount: sudo umount /where/ever sudo cryptsetup luksClose cr_cifs_backup sudo losetup -d /dev/loop0
How can I create an encrypted, file-system–agnostic, mountable volume?
1,490,733,977,000
On OpenBSD, how/with what I can create an encrypted container that can later be dynamically expanded? Can I do it with GPG? (password protection is enough) So, if I open this container and put files in it, it would dynamically expand as more files are put in it. Please do not recommend a Linux solution (e.g. TrueCrypt) without checking that it works on OpenBSD.
The official encrypted container on OpenBSD is through vnode pseudo devices, set up with vnconfig. As far as I know, these cannot be resized: you'd have to create another, larger container and copy the data. Encfs is a FUSE flesystem that performs encryption file by file (so there is no container size issue). There is a FreeBSD port, which I think could easily be adapted to OpenBSD. An alternative approach is to use gpg. You can edit the file in an editor such as Emacs or Vim that automatically decrypts and encrypts the file on the fly. But if you want to use the file in some other application, you'll have to encrypt and decrypt manually.
How to create an encrypted container (dynamically expandable) on OpenBSD
1,490,733,977,000
Can I use luks (as in OpenSSL) to encrypt bash output? e.g with OpenSSL: echo "test" | openssl ..... Can I do that with Luks/Cryptsetup in some way? Like this: echo "test" | Luks...
LUKS is not a command, it is name of a technology and/or metadata format so no, you can't use LUKS for encrypting strings. Same applies for cryptsetup which is only a userspace tool (library) for configuring and managing the LUKS/dm-crypt devices and doesn't do the encrypting itself -- data written/read to/from the device is encrypted by the device mapper crypto plugin in kernel using the kernel crypto API, cryptsetup only tells kernel to create such device and provides encryption key for it (and also takes care of key management) everything else happens in device mapper. If you only want to use cryptsetup in a non-interactive way to create an encrypted device, that is of course possible: printf %s "$password" | cryptsetup luksFormat /dev/sdxY - and similarly for unlocking the device printf %s "$password" | cryptsetup luksOpen /dev/sdxY name - and then you can write your data to /dev/mapper/name and close it afterwards using cryptsetup close name. You can create a disk image and use it directly (so cryptsetup luksOpen disk.img name instead of using a block device), but to actually encrypt something you still need to write it to the created device mapper device.
Is it possible to use luks on output in bash?
1,490,733,977,000
I encrypted a text file in terminal using "gpg -c filename" and got "filename.txt.gpg" created in my file manager. I deleted the original unencrypted file. Now I want to decrypt it in Nano so I can continue working on it. If, in a terminal, I do "gpg -d filename.txt.gpg", the file opens in terminal where I can read it, but do nothing else. I want to open the encrypted file in Nano, and add data to the file in Nano. I've tried every way I can think of, but not able to decrypt and open the file in Nano. Any ideas? Thx.
gpg -d just prints the file to standard output, but you can redirect the output to a file instead: gpg -d filename.txt.gpg > filename.txt. Or use the -o outputfilename option. Also, you can just run gpg filename.txt.gpg, which cause gpg to guess what you want, and in that case it decrypts the file to filename.txt (dropping the final .gpg). Of course, note that when you decrypt the file on a regular filesystem, the OS may write it to the disk and removing the file afterwards will not clear remains of the file data from the disk. To avoid that, make sure to decrypt sensitive data only to RAM based filesystems. On Linux, that would be the tmpfs filesystem. In some distributions, /tmp is a tmpfs by default. If it isn't, you can mount a new tmpfs simply with mkdir /ramfs; mount -t tmpfs tmpfs /ramfs (as root, change the ownership and permissions as required). Just mounting a filesystem doesn't mean that your files would be saved there, but a full discussion of safely handling sensitive data is outside the scope of this answer.
How decrypt a file in nano text editor?
1,490,733,977,000
Are the benefits of btrfs lost if one uses encryptFS on top? What advantages (over ext4) of btrfs remain intact with encryptFS? If I want to have the full benefits of btrfs with encryption, is LUKS the way to go?
Yes use LUKS under btrfs. EncryptFS on top would negate; Transparent compression Data deduplication Copy-on-write ( because COW is on partial file hunks and encryptFS would re-encrypt the whole file )
Are btrfs advantages negated with over-the-top encryption?
1,490,733,977,000
When using openssl version 1.0.2m, I encrypted my test file as follows: openssl enc -aes-256-cbc -salt -in test.txt -out test.txt.enc Just entering password, that's what I wanted. Now, the question is, when decrypting the file, will I in the future need this salt or whatever that is? Or I don't really understand where is that salt stored.
The salt (or IV, initialization vector) is just used to randomize the encryption. Without one, identical inputs lead to identical outputs, which leaks information (namely the fact that the messages are the same). I think I've mostly seen it called "salt" in connection with password hashing, and usually IV in encryption, but the idea is the same. See e.g. Salt_(cryptography) and Initialization vector on Wikipedia. crypto.stackexchange.com and security.stackexchange.com would also have more information on both. The salt is stored in the output file, so you don't need to save it explicitly. You can see that the output file is smaller if you give the -nosalt flag instead.
Confused about salt in openssl encrypt file
1,490,733,977,000
Which command would you suggest to use in order to find out whether a LUKS encrypted partition is mapped or not (other than looking at or using lsblk output)? By opened device, I mean a device for which the command ctrytpsetup luksOpen <device> <map name> was executed.
I would do it like this: $ sudo dmsetup ls crypthome (254:0) $ sudo dmsetup -v table /dev/mapper/crypthome Name: crypthome State: ACTIVE Read Ahead: 256 Tables present: LIVE Open count: 1 Event number: 0 Major, minor: 254, 0 Number of targets: 1 UUID: CRYPT-LUKS1-87863643a6aa43c191f69ee3a2b3301a-crypthome 0 870313984 crypt aes-xts-plain64 0000000000000000000000000000000000000000000000000000000000000000 0 8:2 4096
How to find out whether a LUKS encrypted partition is opened of closed?
1,490,733,977,000
I am trying to extract modulus and exponent components from public key which is in .pem file, using below command: openssl rsa -inform der -pubin -text < pubkey.pem But it is showing me below error message: unable to load Public Key 4339:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/asn1/tasn_dec.c:1315: 4339:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/asn1/tasn_dec.c:379:Type=X509_PUBKEY Any clues?
If you already have the public key try to replace the der option with PEM like this: openssl rsa -inform PEM -pubin -text < pubkey.pem Otherwise you can extract the public key from the key.pem file like this: openssl rsa -in key.pem -pubout -out pubkey.pem and then run the first command again.
Unable to extract modulus, exponent from pubkey.pem
1,490,733,977,000
I installed Fedora 14 first, then Ubuntu 10.04. I installed them using dm_crypt/aes256/lvm, so I used encrypted VolumeGroups. At the end of the Ubuntu install it said it cannot install GRUB, so I had to use SuperGRUBdisk to start Fedora and give the command: # grub-install /dev/sda Now I can boot to Fedora normally, without using supergrubdisk, but the problem is, I can't boot to Ubuntu! Is there any working way to install Fedora 14 & Ubuntu 10.04 using (separated) encrypted VolumeGroups (each volumegroup with other password)? Such that 2 users (who knows the root passwords of their own distro) can use 1 PC but not see each other's files? Update: I tried it in reverse order: I first installed the Ubuntu, then the Fedora. Fedora didn't gave error messages regarding grub when installing, but it's still the same: I can't see the Ubuntu in the "grub boot list", when booting the PC. What could be the problem? The boot manager doesn't recongize that, that there is another distro on the HDD? Why? What should i do? Update#2: Here is my idea on a picture :) (on other pict. host) Update#3: I'm trying this whole thing in VirtualBox (VirtualBox-3.2-3.2.12_68302_fedora14-1.i686)
I manually edited the Fedoras /boot: I appended a few things to the "/boot/grub/menu.lst"!!! and i could boot in to Ubuntu! The Fedora's "/boot/grub/menu.lst" before editing it: # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,2) # kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-LogVol01 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=0 splashimage=(hd0,2)/grub/splash.xpm.gz hiddenmenu title Fedora (2.6.35.6-45.fc14.i686) root (hd0,2) kernel /vmlinuz-2.6.35.6-45.fc14.i686 ro root=/dev/mapper/VolGroup-LogVol01 rd_LVM_LV=VolGroup/LogVol01 rd_LUKS_UUID=luks-af599498-b495-483f-bd1b-fb8d10c8b37a rd_LVM_LV=VolGroup/LogVol00 rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet initrd /initramfs-2.6.35.6-45.fc14.i686.img I appended this, and it worked: title ubuntu root (hd0,0) kernel /vmlinuz-2.6.32-28-generic initrd /initrd.img-2.6.32-28-generic Ok. But there are still two questions: 1) is this booting method ok? (i mean there are many things declared in the fedora's kernel line, and in the ubuntu kernel line, i had just wrote "vmlinuz-2.6.32-28-generic" - i couldn't just copy from the ubuntu's /boot/grub/menu.lst, because there is just grub.cfg..other syntax: http://pastebin.com/raw.php?i=b4DLweKv ) 2) is this manual modification to the menu.lst permanent? Is it ok in long-term? I mean if the ubuntu get's a kernel update, and ubuntu isn't handling/updating the boot manager (because fedora does it, if i install fedora lastly) - then how could the boot manager know, that ubuntu must boot with a new kernel?? or i have to find out what to write in the "kernel" and "initrd" line manually?
How to install Fedora&Ubuntu with encrypted VG's on one disk?
1,700,951,132,000
Preface: I used to run TrueNAS (SCALE) which is where I originally created the tank pool. On Ubuntu Server, I'm trying to assign/change the key of a newly created pool but I am getting the error Key change error: Dataset not encrypted.: user@homeserver:~$ sudo zfs change-key -o keylocation=file:///path/to/zpool.key -o keyformat=raw flash Key change error: Dataset not encrypted. user@homeserver:~$ zfs get encryption tank NAME PROPERTY VALUE SOURCE tank encryption aes-256-gcm - user@homeserver:~$ zfs get encryption flash NAME PROPERTY VALUE SOURCE flash encryption off default This is the command I used when I created the pool: sudo zpool create -o failmode=continue -o autoexpand=on -o autotrim=on -o feature@async_destroy=enabled -o feature@empty_bpobj=enabled -o feature@lz4_compress=enabled -o feature@multi_vdev_crash_dump=enabled -o feature@spacemap_histogram=enabled -o feature@enabled_txg=enabled -o feature@hole_birth=enabled -o feature@extensible_dataset=enabled -o feature@embedded_data=enabled -o feature@bookmarks=enabled -o feature@filesystem_limits=enabled -o feature@large_blocks=enabled -o feature@large_dnode=enabled -o feature@sha512=enabled -o feature@skein=enabled -o feature@edonr=enabled -o feature@userobj_accounting=enabled -o feature@encryption=enabled -o feature@project_quota=enabled -o feature@device_removal=enabled -o feature@obsolete_counts=enabled -o feature@zpool_checkpoint=enabled -o feature@spacemap_v2=enabled -o feature@allocation_classes=enabled -o feature@resilver_defer=enabled -o feature@bookmark_v2=enabled -o feature@redaction_bookmarks=enabled -o feature@redacted_datasets=enabled -o feature@bookmark_written=enabled -o feature@log_spacemap=enabled -o feature@livelist=enabled -o feature@device_rebuild=enabled -o feature@zstd_compress=enabled -o feature@draid=enabled flash mirror /dev/disk/by-partuuid/XXX /dev/disk/by-partuuid/XXX What am I doing wrong and how can I encrypt flash the same way tank is encrypted?
Native ZFS encryption does not encrypt pools, it only encrypts filesystems. Further, per-filesystem encryption has to be set up at the time the filesystem is created. In the case of the pool's root filesystem, this means that encryption of the root filesystem must be set at the time the pool is created. So to create a new pool with an encrypted root filesystem in a similar fashion to that of your existing pool, begin by destroying the new pool: # zpool destroy flash Then re-create the pool, merging your zpool create command above with these additional options. Note the use of capital -O: # zpool create \ (your options from above) \ -O encryption=on \ -O keyformat=(whatever) \ -O keylocation=(whatever) \ flash \ mirror /dev/gpt/diskA-serial-num /dev/gpt/diskB-serial-num Finally, verify: # zfs get encryption,keyformat,keylocation flash NAME PROPERTY VALUE SOURCE flash encryption aes-256-gcm - flash keyformat (whatever) - flash keylocation (whatever) local
How can I encrypt a ZFS pool?
1,700,951,132,000
I followed instructions on Speeding up LUKS decryption in GRUB - GRUB/Tips and tricks - ArchWiki. And I created Full Disk Encryption using the guide: Full_Disk_Encryption_Howto_2019 - Community Help Wiki. I want to decrease the iterations for my encrypted boot partition: $ sudo cryptsetup luksDump /dev/nvme0n1p1 LUKS header information for /dev/nvme0n1p1 Version: 1 Cipher name: aes Cipher mode: xts-plain64 Hash spec: sha256 Payload offset: 4096 MK bits: 512 MK digest: ec 22 27 de c1 ef 40 0f a5 cf 37 d3 96 5c d5 b2 6e c8 dd 90 MK salt: 62 1a 05 81 ba 60 3b 0d b1 8a 9f f0 04 98 27 54 06 b6 8d 72 53 23 09 47 ea 5f 80 1d d7 c5 ca 50 MK iterations: 305173 UUID: 586de9a0-14c7-40d7-b721-7fdba2e3b184 Key Slot 0: DISABLED Key Slot 1: ENABLED Iterations: 4882774 Salt: 2a 22 d6 07 a3 48 ad 83 f9 f4 03 a4 a1 e7 95 ab 2c 95 82 cf c1 73 99 1c 74 70 00 5b b8 1b bf 5f Key material offset: 512 AF stripes: 4000 Key Slot 2: ENABLED Iterations: 4888466 Salt: 65 fe 32 1d c4 c6 1b 38 28 4c 19 3c c0 27 5a d9 83 92 13 8e f4 84 61 00 b5 f6 6c f8 75 15 36 52 Key material offset: 1016 AF stripes: 4000 Key Slot 3: ENABLED Iterations: 4888466 Salt: ce 5b b3 e1 f4 85 45 db fd 49 79 71 b1 02 c7 dc d7 60 a6 36 8b 82 95 20 8e 6e 1d ce 2b 35 1b 13 Key material offset: 1520 AF stripes: 4000 Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED We can see that 3 slots are enabled. Changing the number of iterations $ sudo cryptsetup luksChangeKey --pbkdf-force-iterations 1000 /dev/nvme0n1p1 Enter passphrase to be changed: Enter new passphrase: Verify passphrase: $ sudo cryptsetup luksDump /dev/nvme0n1p1 LUKS header information for /dev/nvme0n1p1 Version: 1 Cipher name: aes Cipher mode: xts-plain64 Hash spec: sha256 Payload offset: 4096 MK bits: 512 MK digest: ec 22 27 de c1 ef 40 0f a5 cf 37 d3 96 5c d5 b2 6e c8 dd 90 MK salt: 62 1a 05 81 ba 60 3b 0d b1 8a 9f f0 04 98 27 54 06 b6 8d 72 53 23 09 47 ea 5f 80 1d d7 c5 ca 50 MK iterations: 305173 UUID: 586de9a0-14c7-40d7-b721-7fdba2e3b184 Key Slot 0: ENABLED Iterations: 4888466 Salt: 93 c2 c4 fe 95 ab 24 44 9e dd 26 90 c1 cf a2 66 19 80 d3 4b f9 e8 b3 5a 0e a1 9f 6a de d8 60 ea Key material offset: 8 AF stripes: 4000 Key Slot 1: ENABLED Iterations: 4882774 Salt: 2a 22 d6 07 a3 48 ad 83 f9 f4 03 a4 a1 e7 95 ab 2c 95 82 cf c1 73 99 1c 74 70 00 5b b8 1b bf 5f Key material offset: 512 AF stripes: 4000 Key Slot 2: ENABLED Iterations: 1000 Salt: 65 fe 32 1d c4 c6 1b 38 28 4c 19 3c c0 27 5a d9 83 92 13 8e f4 84 61 00 b5 f6 6c f8 75 15 36 52 Key material offset: 1016 AF stripes: 4000 Key Slot 3: DISABLED Key Slot 4: DISABLED Key Slot 5: DISABLED Key Slot 6: DISABLED Key Slot 7: DISABLED Questions After changing the number of iterations, we can see that previously keyslot 0 was disabled and not it has got enabled. Is it a random assignment of key slots? Is that important? To speed up the boot, do I require to decrease the iterations of all keyslot to 1000? As, I remember key slots are checked sequentially. How can I make iterations as 1000 for all key slots? Is the information displayed by above commands private and should not be shared?
(1.) cryptsetup swaps keyslots around for internal reasons, unfortunately you just have to deal with it. From the cryptsetup luksChangeKey manpage: If a key-slot is specified (via --key-slot), the passphrase for that key-slot must be given and the new passphrase will overwrite the specified key-slot. If no key-slot is specified and there is still a free key-slot, then the new passphrase will be put into a free key-slot before the key-slot containing the old passphrase is purged. If there is no free key-slot, then the key-slot with the old passphrase is overwritten directly. It also mentions one of the reasons why it prefers to shuffle the keyslots around: WARNING: If a key-slot is overwritten, a media failure during this operation can cause the overwrite to fail after the old passphrase has been wiped and make the LUKS container inaccessible. Some cryptsetup commands let you specify the keyslot to be used, e.g. you can remove a specific slot or add a new key to a specific free slot. So there are various ways to get the keys in the order you want. (2.) It's preferable to put the key you most often use into the first slot. Otherwise the slow slots will be tried first. It's also possible to specify the desired keyslot on cryptsetup open, but GRUB probably doesn't support it. For LUKS 2, the keys are also not tried in keyslot order at all. Instead it depends on the order stored in the JSON metadata, as well as a keyslot priority you can set with cryptsetup config --priority, but I don't know if GRUB would honor that. (3.) By changing each of them, or otherwise by removing the offending ones. (Consider making a backup of the LUKS header before removing keys, as it's possible to lock yourself out this way.) (4.) It's not possible to derive a LUKS master key or passphrase from luksDump output as the key material is missing entirely. But if you lose this drive somewhere and whoever found it googles the UUID, they might find your post and identify you this way…
Speeding up LUKS decryption in GRUB using pbkdf-force-iterations
1,700,951,132,000
Is there any way to check if a LUKS device is unlocked, without having sudo permissions? I'm aware of two questions, but all the answers require sudo. It seems that I've found an indirect way (processing the CleartextDevice value of udisksctl info's output), but even assuming it's a stable solution, it's a hack at best. Gnome-disks, for example, doesn't require sudo permissions, but it still decodes the locked/unlocked status of LUKS devices.
Gnome-disks, for example, doesn't require sudo permissions, but it still decodes the locked/unlocked status of LUKS devices. GNOME Disks uses UDisks to get the information. There's nothing hacky about it, the CleartextDevice property will be always either / if the device is locked or a valid object path in form of /org/freedesktop/UDisks2/block_devices/dm_2d<num>, where dm_2d<num> translates to dm-<num>, the device mapper cleartext device name (- is encoded as _2d on DBus). If you don't want to parse udisksctl output, you can use busctl to get only the CleartextDevice property. It can also format the output in JSON for simpler parsing. Locked LUKS device: $ busctl get-property org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/sda1 org.freedesktop.UDisks2.Encrypted CleartextDevice -j { "type" : "o", "data" : "/" } Unlocked LUKS device: $ busctl get-property org.freedesktop.UDisks2 /org/freedesktop/UDisks2/block_devices/nvme0n1p3 org.freedesktop.UDisks2.Encrypted CleartextDevice -j { "type" : "o", "data" : "/org/freedesktop/UDisks2/block_devices/dm_2d0" } UDisks DBus API is guaranteed to be stable, the object path for the device will be always /org/freedesktop/UDisks2/block_devices/<name>. But you can always simply check whether the LUKS device has a child. The cleartext device will always be a child of the LUKS device so you can check either from lsblk or from sysfs. Locked LUKS device: $ ls /sys/block/sda/sda1/holders/ Unlocked LUKS device: $ ls /sys/block/nvme0n1/nvme0n1p3/holders dm-0
How to check if a LUKS device is unlocked, without sudo permissions?
1,700,951,132,000
Hello I have a question about LUKS encryption. I have used LUKS to encrypt a disk on my server but when I create a file and add content to it, and cat the file, the content is still in plain text. Even when I create a backup of the file, and put it on the non-encrypted hard drive, the data is in plain text. I'm not sure how I can say that encryption is happening. Am I missing something? Is this how LUKS is supposed to work? /dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS" [root@host1 ~]# cat /opt/my_encrypted_backup/test12 This is a test [root@host1 ~]# clear [root@host1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 8G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 7G 0 part ├─centos-root 253:0 0 6.2G 0 lvm / └─centos-swap 253:1 0 820M 0 lvm [SWAP] sdb 8:16 0 1G 0 disk └─mybackup 253:2 0 1022M 0 crypt /opt/my_encrypted_backup sr0 11:0 1 1024M 0 rom [root@host1 ~]# [root@host1 ~]# [root@host1 ~]# blkid /dev/sdb /dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS" [root@host1 ~]# [root@host1 ~]# [root@host1 ~]# cat /opt/my_encrypted_backup/test12 This is a test [root@host1 ~]# cp /opt/my_encrypted_backup/test12 / [root@host1 ~]# cat /test12 This is a test [root@host1 ~]#
LUKS/dm-crypt works on the block device level, not on the filesystem level so yes, this is correct and this is how it works. When you open the encrypted device (/dev/sdb in your case) a new virtual device mapper device is created (/dev/mapper/mybackup in your case) on top of it. All data on sdb is encrypted and mybackup is used to access the data in plain -- from system point of view, mybackup contains a normal unencrypted filesystem and everything on it is unecrypted, this way the system can work with encrypted data without need for additional encryption support in every application that reads/writes data to disk. When data is read from mybackup, device mapper (kernel module) reads the data from sdb and decrypts it before returning it in plain text. Similarly for writes, you write plain text to mybackup and before writing to sdb it's encrypted. So everything on your disk is accessible in plain text when the device is opened. So your data is "safe" only when the device is not opened. Main use case for LUKS/dm-crypt (or disk encryption in general) is to protect the data in case of your disk (or entire computer) gets stolen. It does not protect the data when the system is running and the device is opened because the master key is stored in memory, you can get it using dmsetup table --showkeys.
Unable to validate LUKS encryption
1,700,951,132,000
I applied encryption with fscrypt on my home folder on Linux Mint. But now I decided to remove encryption and try something else. I read through the readme of the project, but I couldn't really find exact instructions, how to remove encryption. I have an assumption it could be done maybe by making a backup and deleting the home folder itself and with the fscrypt metadata command. But I'm not sure about it. Does anyone know the exact steps to achieve this.
I think you can't remove encryption. So to achieve that : Copy home files elsewhere (note that having good backups is considered a good practice) Remove /home/theuser directory Create a new /home/theuser directory and apply owner-group permissions Copy files back home enjoy
How to remove encryption from a directory encrypted with fscrypt?
1,700,951,132,000
I'm trying to install Kubuntu 20.04 with LVM encryption on a dual-boot machine. Previously, I'd done this on Mint per these simple steps. In brief, all you have to do setup your partitions manually during the install process: you choose "physical volume for encryption," it prompts you for the password, & creates an ext4 encrypted volume which I then set its mount point to "/" (& change to btrfs). But in the Kubuntu installer this doesn't work. If you select "physical volume for encryption," nothing happens. After some googling, I found this bug report showing that their installer has had this bug for nearly half a decade. So the question: since it doesn't seem like the Kubuntu team will be fixing their installer anytime soon, how would one manually setup a similar partition layout - ideally in the Kubuntu live OS (prior to running the installer)? Can the same installation result be safely achieved in this way? And for clarity, what exactly is the Mint installer doing when you tell it to create a "physical volume for encryption," & then follow its prompts per above?
Finally figured out a working solution: 1) Follow the extremely thorough instructions here... 2) ...But instead of using his installation script, grab the btrfs-friendly alternative from here... 3) ...And make one manual edit: change the invocation of "cryptsetup luksFormat" to add "--type=luks1". Because per here: The default LUKS (Linux Unified Key Setup) format used by the cryptsetup tool has changed since the release of 18.04 Bionic. 18.04 used version 1 ("luks1") but more recent Ubuntu releases default to version 2 ("luks2"). GRUB only supports version 1 so we have to be explicit in the commands we use or else GRUB will not be able to install to, or unlock, the encrypted device.
Installing Kubuntu with Manual Partitioning & Encryption
1,700,951,132,000
Google cloud services (computing instance) offer encryption by default for disk storage, the customer can provide its own key with the feature customer supplied encryption (detailed here also). How can we apply a disk encryption with cryptsetup without giving the encryption key to google?
On Linux, when using an encrypted disk (luks), it is unlocked at boot time with a password the idea here is to encrypt the disk with cryptsetup on top of the google system (default encryption) and get an earlier access to the instance to be able to unlock the drive at the boot time. This can be implemented with the help of the remote serial console feature (note that an opensuse VM was used for this howto, the different steps should not differ for other distros). Con: Disk speed will be reduced by 10~15%. At boot/reboot time the encryption password need to be introduced over a serial session. Reboot on failure/migration may require manual password introduction (if not automated). Pro: Data access is truly limited to the customer/owner. Customer privatized disk encryption at rest. Customer privatized disk encryption for snapshot backups and images. Google can not access the disk's data (or at least it would be very hard). The disk encryption key is not given to Google. Customizable encryption method, algorithm and key size. Data protection improvement etc. Implementation summary: 0 Have an existing VM instance 1 Enable instance/VM serial access 2 Create an additional (target) encrypted hard drive 3 Copy the current hard drive to the encrypted one 4 Replace the old drive with the new one 5 Start the VM and introduce the password over the serial console How to encrypt the disk of a VM (gcloud, cryptsetup): Prerequisite: Create a new temporary VM on the target zone (this need to be a copy of the target machine, you can backup the disk with a snapshot then restore the snapshot to a new disk) Create a new empty disk (to be encrypted later), this is the target disk, its size need to be at least 256 MB larger than the source disk (for the new /boot partition), also the disk can be more larger if you want to expand the space. Mount both disks to the temporary VM and start it. Temporary VM Config: /dev/sda : main disk, copy of the original source disk /dev/sdb : new empty disk larger than /dev/sda Serial console: Summary: enable serial port connection, and connect to the machine over serial port (doc1, doc2, doc3) Under metadata add serial-port-enable with the value TRUE (and enable serial port on the instance options) Connect to the serial port with ssh/gcloud; gcloud example: gcloud compute --project=prj-name connect-to-serial-port vm-name --zone=us-central2-b Update grub config: Summary: enable serial console (makes grub accessible with the serial console) Add/edit this to /etc/default/grub # ...Enabling serial console... GRUB_TIMEOUT=15 GRUB_TERMINAL="serial" GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" # ...End Apply the settings with grub2-mkconfig -o /boot/grub2/grub.cfg Reboot and check if grub is accessible on the serial console. Format the target disk: Summary: we need to create 2 partitions one for /boot (un-encrypted) and an other for the system / (encrypted), it does not matter if you already had a separate partition for /boot or not on your old system, on the new one we would need to have it for the system to boot grub and ask for the password to unlock the encrypted partition. Format the empty disk and create 2 partitions one sized at least 256 MB (to contain /boot) and the other one with the remaining space; Use fdisk /dev/sdb to do so, create the first one with 256 MB or more as a primary parition and enable the bootable flag; then create a second primary partition sized with the remaining space (note that if you were using a partition for the swap on the old system you need to create that partition as well) /dev/sda : /dev/sdb : |- sdb1 : 256 MB primary and bootable (empty) |- sdb2 : xx GB primary (empty) Set the file system to ext4 for the boot partition with mkfs.ext4 /dev/sdb1 Wipe the second partition for an additional security with dd if=/dev/urandom of=/dev/sdb2 bs=4096 status=progress Setup the encryption for sdb2 with cryptsetup -y -v --cipher aes-xts-plain64 --key-size 256 --pbkdf-force-iterations=100200 --hash sha256 --type luks1 --label=linux --use-random luksFormat /dev/sdb2 Change the cipher, the key size, encryption type etc. to match your needs Check the encrypted partition with cryptsetup luksDump /dev/sdb2 Unlock the encrypted partition with cryptsetup luksOpen /dev/sdb2 crypteddisk Set the encrypted mapped partition to ext4 with mkfs.ext4 /dev/mapper/crypteddisk Close the encrypted partition cryptsetup close /dev/mapper/crypteddisk Clone the source disk: Summary: we need to copy our system / to the new encrypted partition /dev/mapper/crypteddisk (sdb2) for this step you can use different tools, in this howto we will be using dd, important note here, for dd to copy a disk without any error the source partition need to unmounted. If you want to avoid any data loss you can create an other temporary VM and attach to it the source and target disk as additional disks to perform this step... Otherwise to avoid a too long migration process i closed most of the running process and used dd without un-mounting the source partition (not recommended), then used fsck to correct any error due to the fact that the source was not un-mounted. Unlock the encrypted partition with cryptsetup luksOpen /dev/sdb2 crypteddisk Copy the source partition to the target with the following (supposing / is /dev/sda1) dd if=/dev/sda1 of=/dev/mapper/crypteddisk bs=4096 status=progress Check and fix the new encrypted partition with fsck /dev/mapper/crypteddisk Check the disks structures with fdisk -l (don't pay attention to crypteddisk size, we are fixing that later) Partitions UUID: Get all the UUID of all the partitions and keep that info. blkid /dev/sda blkid /dev/sda1 blkid /dev/sdb blkid /dev/sdb1 blkid /dev/sdb2 blkid /dev/mapper/crypteddisk Resize the disk: Summary: in this step we will expand the size of the new encrypted partition. Expand the encrypted partition with cryptsetup resize crypteddisk -v e2fsck -f /dev/mapper/crypteddisk resize2fs /dev/mapper/crypteddisk Backup the MBR: This is not required but it may be useful dd if=/dev/sdb of=/backup/location/sdb.mbr count=1 dd if=/dev/sda of=/backup/location/sda.mbr count=1 Setup the boot partition: Mount the new boot partition and copy /boot content to it. mkdir /tmp/boot mount /dev/sdb1 /tmp/boot cp -a /boot/* /tmp/boot/ ls -l /tmp/boot/* umount /tmp/boot rmdir /tmp/boot Remove the old /boot folder content and leave it as a mount location. mkdir /tmp/system mount /dev/mapper/crypteddisk /tmp/system rm -rf /tmp/system/boot/* ls -l /tmp/system/boot/* umount /tmp/system rmdir /tmp/system Chroot and setup the new system: Load the new encrypted disk as the current one (chroot) and setup it to apply the new system config, encryption etc. (also make sure /mnt is empty before proceeding). mount /dev/mapper/crypteddisk /mnt/ mount /dev/sdb1 /mnt/boot for i in sys dev proc; do mount --bind /$i /mnt/$i; done chroot /mnt From now on we are on the new system (keep in mind that sdb need to be considered sda on the configs files) Update /etc/fstab config (make sure to use sdb1 uuids not sda1), here is cat /etc/fstab output: # Main Partition ---------------------- # Entry for /dev/mapper/crypteddisk (sda2) : UUID=CHANGE-THIS-WITH-CRYPTEDDISK-UUID / ext4 noatime,acl 0 0 # Boot Partition ---------------------- # Entry for /dev/sda1 : #/dev/sda1 /boot ext4 defaults 1 2 UUID=CHANGE-THIS-WITH-THE-CURRENT-SDB1-UUID /boot ext4 noatime,acl 1 2 # Swap Partition/File ----------------- /swap/swapfile swap swap defaults 0 0 # Update /etc/crypttab config (if crypttab file does not exist, create it with -rw-r--r-- permissions), also make sure to use sdb2 uuids not sda1 nor crypteddisk, here is cat /etc/crypttab output: crypteddisk UUID=CHANGE-THIS-WITH-CURRENT-SDB2-UUID Update the grub config on /etc/default/grub, you only need to change GRUB_ENABLE_CRYPTODISK, GRUB_CMDLINE_LINUX and GRUB_DISABLE_OS_PROBER here is cat /etc/default/grub output: GRUB_DISTRIBUTOR=My-Custom-Server... # .................................... Command line #GRUB_CMDLINE_LINUX=" root=/dev/sda1 disk=/dev/sda resume=swap console=ttyS0,38400n8 quiet" GRUB_CMDLINE_LINUX=" root=/dev/mapper/crypteddisk luks_root=/dev/sda2 luks="root" disk=/dev/sda resume=swap console=ttyS0,38400n8 quiet" # .................................... Options GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_GFXMODE=800x600 GRUB_GFXPAYLOAD_LINUX=keep GRUB_THEME=/boot/grub2/theme/theme.txt GRUB_BACKGROUND= # .................................... Enabling serial console... GRUB_TIMEOUT=30 GRUB_TERMINAL="serial" GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" # .................................... Enabling cryptsetup GRUB_ENABLE_CRYPTODISK="y" # .................................... Ignore other os GRUB_DISABLE_OS_PROBER="true" # .................................... Apply grub changes with: grub2-mkconfig -o /boot/grub2/grub.cfg Update the init ram disk and force encryption modules to be included with: mkinitrd -d /dev/mapper/crypteddisk -f "dm luks" Update the MBR and reinstall grub on the new disk to make it bootable grub2-install /dev/sdb Exit the chroot and un-mount everything exit cd / for i in sys dev proc; do umount /mnt/$i; done unmount /mnt/boot unmount /mnt If you have any issue un-mounting a partition use -l option for instance umount -l /mnt/sys Apply the magic: Turn off the temporary VM; Detach all the disks; Attach the encrypted disk as the boot disk. Turn on the temporary VM; Connect to it with the serial console and voila! (you will be asked the password to unlock the crypted partition at boot time). Test if everything is fine, then use the new encrypted disk on the production VM and delete the temporary copy disk and the temporary VM. Additional infos are available here and here. Enjoy ;)
How to force a custom disk encryption on a google cloud compute instance (gcloud)?
1,700,951,132,000
I need to run a script as a regular user on a remote machine whose root I do not trust. This script outputs very sensitive data to stdout. What steps can I take to ensure only I can read the script’s output? What steps can I take to ensure remnant files on the disk (if there are any) are permanently destroyed?
Root has all privileges on the machine, so there's no way you can protect stdout from root. If the data had only to transit through the machine (e.g. via a network interface) a solution would be to encrypt it at the source, but since the data is generated on the same machine the root user can easily modify the script to fetch the unencrypted data. As a rule, if you don't trust a machine, don't run anything on it. Also, there's a contradiction in the sentence "This script outputs very sensitive data to stdout" -- if it's very sensitive data, you shouldn't dump it to stdout, unless you are the only user on the machine.
Privacy as regular user against root?
1,700,951,132,000
Suppose these two operating systems and SSH software: GNU/Linux Debian 9.3 with OpenSSH version 1:7.4p1-10+deb9u2 Linux Mint 18.3 with OpenSSH version 1:7.2p2-4ubuntu2.4 And I want to switch away from rsa completely to the benefits of curve ed25519. The question is, after I generate ed25519 on both systems with: ssh-keygen -t ed25519 And copy the public keys with ssh-copy-id, shall I delete the rsa key-pair with rm or is that a wrong way?
No, deleting the key pair is fine. All you have to do is to delete your public key from the server. However, you don't remove it with rm; you delete the relevant lines from the ~/.ssh/authorized_keys file. Check first that you can log in with your new key pair! For cleanliness, I'd also suggest you to remove your private key from the client machine, although that would make no difference.
What is the correct way to remove RSA key-pair entirely from my SSH configuration?
1,700,951,132,000
I'd like to encrypt my home folder in CentOS. I notice Dovecot has created directories and files under ~/mail. If I encrypt, will my email stop working (remote access over imap and smtp)?
Your unencrypted directory is available only when you are logged in, it's a fake filesystem provided by the decryption program. When you're logged out, the fake (decrypted) filesystem does not exist. dovecot, at, cron cannot see it. Reconfigure dovecot to only use files/dirs that exist while you're logged out.
Encrypted home folder and email
1,700,951,132,000
I'm trying to following this documentation (see section Create a Code Signing Certificate) in oder to encrypt a p12 file but I always receive the same warning. unknown option 'Cert.p12' Am I doing something wrong? This is the command I'm running openssl enc -aes-256-cbc -a -salt -k -in "Cert.p12" -out "Cert.p12.encrypted"
You have a error in your command. The -k option requires a password. From the man enc page: -k password the password to derive the key from. This is for compatibility with previous versions of OpenSSL. Superseded by the -pass argument. As you can see, the option has been superseded by the -pass option. Therefore a better interactive command for you would be (note the lack of the -k option): openssl enc aes-256-cbc -a -salt -in "Cert.p12" -out "Cert.p12.encrypted" at which point it will prompt for a password. If you must have the password in a script (which is dangerous) then use the -k option or the newer -pass pass:<your password>. Read man openssl's PASS PHRASE ARGUMENTS section for more secure ways of passing the password. Note that you can drop the enc, which is implied when you specify a cipher and -salt which is enabled by default. You can therefore use: openssl aes-256-cbc -a -in "Cert.p12" -out "Cert.p12.encrypted" The default option for openssl is to encrypt, so you don't need to instruct it to do so. However, to decrypt you need to add the -d option: openssl aes-256-cbc -d -a -in "Cert.p12.encrypted" -out "Cert.p12.copy"
Encrypting a p12 certificate
1,700,951,132,000
I am able to successfully authenticate by typing in the encryption password (and hitting return), but nothing is displayed on the screen to prompt me for this information. I tend to just "wait enough time" before attempting to type in my password. A coworker said he observed the same behavior, but hitting the ESC key while the system was waiting for the password input would force it to draw the prompt.
My first guess would be that for some reason the splash screen is hiding or blocking the passphrase prompt. You can check whether this is the case by switching off the splash screen. To do so, we must make changes to the configuration of the bootloader which in mint should be grub (GRand Unified Bootloader): Start a terminal (if you don't know how, one foolproof way is to press ALT-F2 and enter gnome-terminal Before you make changes to the config file, create a backup you can revert to if anything goes wrong: $ sudo cp /etc/default/grub /etc/default/grub.bkp now you can edit the grub configuration file (nano is a simple and easy to use editor, replace it with your own pick if you prefer): $ sudo nano /etc/default/grub Find the line GRUB_CMDLINE_LINUX_DEFAULT, look for the splash option within the double quotes and delete it. save the file and exit the editor - to do this in in nano, press CTRL-X (nano will ask whether you want to save changes before exiting) now you have made changes to the system-wide default configuration for grub. However, these need to be translated to grubs own config file format to actually take effect. To do so, enter: $ sudo update-grub Now reboot the system. There should be no graphical splash screen anymore, instead some text based boot messages among which you should now be able to see the passphrase prompt when you get to it. (To return to the previous state, you can restore the backup of the configuration file by opening a terminal again, entering sudo mv /etc/default/grub.bkp /etc/default/grub and then sudo update-grub.) Note: If this works, it isn't actually so much a solution as a workaround, since we didn't actually track down the problem and solve it. I haven't worked on either Mint or Ubuntu for quite a while but I remember that there were sometimes problems with missing passphrase prompts on client machines and the quickest (though roughest) remedy was to switch off splash altogether. If my assumption is right and the problem is related to the splash screen, then the actual cause can be anything from wrong options to bugs. But for more indepth troubleshooting, you would need to give more detailed information about your system and propably also someone who has a machine running Mint themselves.
No prompt on boot with full disk encryption enabled
1,700,951,132,000
I created a separate partition on a CentOS install (VirtualBox), and am attempting to encrypt it using cryptsetup and LUKS. I'm using the following commands to get this set up: cryptsetup luksOpen /dev/mapper/VolGroup-db00 db_fips (no error, all clear) mkfs -t ext4 /dev/mapper/db_fips (no error, all clear) e2fsck -f /dev/mapper/db_fips e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/db_fips: 11/131072 files (0.0% non-contiguous), 17196/523776 blocks Ok, the volume is created. So next I reboot. After logging in, the /dev/mapper/db_fips volume is gone. [root@dhcp ~]# ll /dev/mapper/db_fips/ ls: cannot access /dev/mapper/db_fips/: No such file or directory # lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LogVol01 VolGroup -wi-ao---- 1.46g LogVol02 VolGroup -wi-ao---- 500.00m LogVol03 VolGroup -wi-ao---- 1000.00m LogVol04 VolGroup -wi-ao---- 500.00m LogVol05 VolGroup -wi-ao---- 300.00m LogVol06 VolGroup -wi-ao---- 3.00g db00 VolGroup -wi-a----- 2.00g Why is the db_fips volume I just created gone? /dev/mapper/VolGroup-db00 still exists, and shows to be encrypted (?) blkid /dev/mapper/VolGroup-db00 /dev/mapper/VolGroup-db00: UUID="some uuid" TYPE="crypto_LUKS" If /dev/mapper/VolGroup-db00 is what I actually encrypted, why did I need to issue cryptsetup /dev/mapper/VolGroup-db00 luksOpen db_fips, and why is that no longer available?
Creating an encrypted volume does just that: create an encrypted volume on the disk. Using the volume on your live system is a concept that only makes sense as long as the system remains live: it needs to be done all over again if the system reboots. So you need to arrange for the volume to be brought up during the system startup. To do that, list it in the file /etc/crypttab. Add a line like this: db_fips /dev/VolGroup/db00 Your system startup scripts will take care of calling cryptsetup luksOpen; you'll be prompted for the password. This is analogous to listing a filesystem in /etc/fstab so that it is mounted during startup.
luks volume disappears after reboot
1,700,951,132,000
Last weekend there was a cryptographic challenge where the ciphertext was the following hex: FC 89 BF C2 B0 5F 1C 2E 64 B8 78 43 92 78 3A C9 I know for sure that this is encrypted using AES/Rijndael 128-bit ECB, the key is REDRYDER and a solution for this has already been posted to confirm this. The plain text is FLAG=DAISY. I wrote a simple PHP mcrypt script that decrypts this with no salt or no IV string and it decrypts properly. However, when I tried to use openssl, I don't get the plain text: echo "0: FC 89 BF C2 B0 5F 1C 2E 64 B8 78 43 92 78 3A C9" | xxd -r | openssl aes-128-ecb -d -k REDRYDER -nosalt -nopad ; echo This just outputs some binary data. I also tried passing the input through dd conv=swab to do a byte swap. What am I doing wrong?
The openssl command line tool is a demo of the OpenSSL library. It has a pretty haphazard interface and poor documentation. I don't recommend using it for anything other than testing the OpenSSL library. (Yes, there are people who manage CAs with openssl. I fear for their sanity.) AES operates with a key, not with a password. An AES-128 key is exactly 16 bytes. The option -k doesn't take a key as input, it takes a password. This password is hashed to derive a key; the default is MD5 and it can be overridden with command line option -md. This isn't documented in the manual as far as I can see, you just have to read the source (apps/enc.c, call to EVP_BytesToKey). The MD5 digest produces a 16-byte value from any string, but this isn't what was used here. In this case, the key is actually REDRYDER\0\0\0\0\0\0\0\0 where the \0 are null bytes. The option -K lets you pass a key, in hexadecimal. If you pass fewer bytes than the key size, OpenSSL completes with null bytes. So to pass the key REDRYDER\0\0\0\0\0\0\0\0, you can pass $(echo REDRYDER | od -An -tx1 | tr -d ' ') which is 5245445259444552. The AES-128-ECB decryption operation of the ciphertext block FC89BFC2B05F1C2E64B8784392783AC9 with the key 52454452594445520000000000000000 yields 464c41473d4441495359000000000000 (using hexadecimal to represent the byte sequences). That's FLAG=DAISY\0\0\0\0\0\0. For little cryptographic manipulations like these, I like the Python toplevel with the Pycrypto library. >>> from binascii import hexlify, unhexlify >>> from Crypto.Cipher import AES >>> ciphertext = unhexlify('FC 89 BF C2 B0 5F 1C 2E 64 B8 78 43 92 78 3A C9'.replace(' ', '')) >>> key = 'REDRYDER'.ljust(16, '\0') >>> AES.new(key, AES.MODE_ECB).decrypt(ciphertext) 'FLAG=DAISY\x00\x00\x00\x00\x00\x00'
Proper options for openssl with simple ciphertext
1,700,951,132,000
I've written a little script for my Clonezilla USB stick which will allow me to quickly back everything up without entering any options by simply running the script. Next, I'd like to store my public GPG key on the stick and add some encryption to my backups like so: find . -maxdepth 1 -type f -not -iname "*.gpg" | while read file ; do gpg --encrypt-using-key-file "/path/to/my/keyfile" "$file" rm "$file" done What is the way to properly encrypt files using a public GPG keyfile, ensuring that it doesn't prompt for user input? How would I actually do this?
You must have the target key in the keyring. I am not sure whether it is necessary that the target key is valid; better make it so. You should use a config directory on the stick. With this directory being empty you import the key: gpg --homedir /dir/on/stick --import /target/key.asc This needs to be done just once. From your script you do this: gpg --homedir /dir/on/stick --trust-model always --recipient 0x12345678 \ --output /path/to/encrypted_file.gpg --encrypt /source/file You may consider creating a signature for the file, too. But that would make the operation a bit more complicated.
Batch encryption using a public GPG key
1,700,951,132,000
I used ecryptfs-migrate-home to encrypt my home folder on my Debian (Testing) system. As I am a complete encryption-greenhorn, I don't know yet how to check, if the encryption succeeded. However, I suppose encryption works but filenames are not encrypted. I want to have encrypted filenames as well. How can I get encrypted filenames for my (already encrypted) /home-folder?
The encrypted home utilities don't support the ability to enable encrypted filenames after you've set up your encrypted home directory. But, I looked at the ecryptfs-migrate-home script and believe that it should be enabling filename encryption by default. Let's verify that filename encryption is enabled. Do you have two lines in your key signature file? $ wc -l ~/.ecryptfs/Private.sig 2 /home/user/.ecryptfs/Private.sig If wc reports that there are two lines, things are looking good so far. Check to see if the eCryptfs mount includes the filename encryption key signature mount option: $ grep ecryptfs_fnek_sig= /proc/mounts /home/user/.Private /home/user ecryptfs rw,nosuid,nodev,relatime,ecryptfs_fnek_sig=0011223344556677,ecryptfs_sig=8899aabbccddeeff,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs 0 0 If you see the ecryptfs_fnek_sig option, things are looking even better. Now make sure that filenames are encrypted in the lower filesystem: $ ls /home/.ecryptfs/user/.Private Do all filenames have a "ECRYPTFS_FNEK_ENCRYPTED." prefix? If so, the filename encryption feature is configured and working correctly.
setup filename encryption for encrypted home folder in eCryptfs
1,700,951,132,000
Disclaimer I'm not robbing someone, didn't rob someone in the past and don't plan to do so anytime soon. Situation Imagine I own a Samsung 2.5" SSD (850, 860 or the like) which is encrypted. If it's a software encryption like Bitlocker, FileVault or VeraCrypt, I can simply reformat the disk and should be fine. But these Samsung SSDs also come with a AES-256Bit hardware encryption and I don't know the PW. I'm not interested in the data that might be on the disk (or not). Question How do I erase the hardware-encrypted disk without having the PW? My only goal is to repurpose the SSD, not getting access to the data itself.
If I understood you correctly, you don't want to decrypt the disk, you want to make it usable. Linux: Install sedutil and follow this guide: https://superuser.com/a/1769237 Windows: Put this drive into a Windows PC Install Samsung Magician Disable HW encryption.
erase hardware-encrypted SSD
1,700,951,132,000
I have an Arch installation on a LUKS-encrypted LVM. After I installed Debian on a different NVME drive I'm no longer able to cryptsetup open the partition from other systems, nor can I boot into Arch. # cryptsetup open /dev/nvme0n1p3 arch Device /dev/nvme0n1p3 is not a valid LUKS device. Here is a hexdump -C of the first 35kb of said partition. Notes: When I was installing Arch I first made a partition and assigned it as an LVM partition, then set up and opened LUKS, then set up LVM itself. When Arch was operational, sometimes the decryption process would fail and throw me into GRUB rescue shell saying that the logical volume was not found. I presume it's because the motherboard passes NVMEs in different order yet in GRUB config file the partition was set as /dev/nvme0n1p3:<LVM VG:LV>, not as a UUID. Back then it could be fixed by unplugging the laptop's power cable until the decryption prompt appeared. After the failure nothing works anymore, including removing all other drives. Is it toast or can I do something to recover it?
The issue was solved using Method #1 created and kindly suggested by frostschutz. Everything worked out smoothly and without any errors. After dumping and repairing a LUKS header file I was able to use it to open the partition. Then I mounted the volume after scanning for it using lvscan. For more extreme cases there is also Method #2. From now on I'll be smarter and will start making header backups :)
Encrypted LVM "is not a valid LUKS device", cannot boot or open
1,700,951,132,000
I recently learned that Linux supports Adiantum as a disk encryption cipher (run cryptsetup benchmark -c xchacha20,aes-adiantum-plain64 to try it out on your system). While Adiantum is primarily meant to provide faster disk encryption for low-end devices that do not support hardware AES acceleration, it is also a wide block cipher mode, meaning that a single bit flip in the ciphertext randomizes an entire sector of plaintext, whereas in AES-XTS mode (the current recommended cipher when AES acceleration is available) a single bit flip in the ciphertext randomizes only a 16 byte block of plaintext. That gives a potential attacker much more granularity and block boundaries to work with. So in this respect Adiantum is strictly more secure than AES-XTS. Adiantum is a construction built from a hash, a bulk cipher and a block cipher. The currently available variants in my Linux kernel (v5.4) use ChaCha12 or ChaCha20 as bulk cipher. For the intended use on devices without hardware AES acceleration that is great, but now I also want to use it on my laptop with AES acceleration where AES-XTS is about twice as fast as Adiantum. Are there any wide block ciphers for disk encryption optimized for hardware AES acceleration available for Linux, or being worked on? @anyone from the future, if the answer is 'no' at the time I'm writing this but has changed by the time you read this question, please do post an answer with the updates at your time.
The designers of Adiantum also tackled this question and came up with HCTR2. It is similar to Adiantum but uses AES-XCTR as encryption and POLYVAL as accelerated hash function. Available in Linux kernel version 6.
Fast wideblock AES disk encryption in Linux?
1,700,951,132,000
How can I securely mount an encrypted container? I want to encrypt a bunch of small files (let's say my diary). When locked, this should appear as a single file with unreadable contents. When I unlock it, it should be mounted as a file system showing the files and directories inside with a shell opened at the root of the container. The shell should be able to run regular programs like ls, cat, gedit or git. When the shell exits, the container should be unmounted as well. However, even while the container is mounted, it should not be possible for other processes to see its contents - only the shell and its child processes should be able to do this. Is there a way to accomplish this?
I assume you already have a container set up via LUKS. If not, create an empty file using fallocate (not smaller than 100MB), then proceed to cryptsetup luksFormat it like you'd normally set up a LUKS volume. It's (somewhat) possible if you have root privileges; not if you're trying to protect it against someone else who has root on the system. The simplest way to isolate file access is to have the container's files be owned by a dedicated user account – the the isolated shell you describe could be opened using su otheruser. However, I would instead recommend a full login, i.e. having two graphical sessions running side-by-side – your normal account on Ctrl-Alt-F1, your "private diary" account on Ctrl-Alt-F2 – as this would be less hassle trying to grant su access to your "host" X11 or Wayland display. A separate graphical session also has the advantage of avoiding clipboard leaks (e.g. accidentally pasting journal contents into Stack Exchange post), and more importantly – preventing processes on the "host" account from snooping your screen contents and keyboard input, which isn't a problem in Wayland sessions but is trivial in X11. Even if an "outside" process cannot access the file currently loaded into gedit, it can simply screenshot the gedit window. (Finally, it lets you have different GUI themes for the two environments to avoid confusion.) The built-in "fscrypt" file encryption feature in ext4 also keeps track of loaded keys per UID. Another method would be to create a new mount namespace using unshare, as mounts done within a namespace can be made invisible to processes in the "parent" namespace. (It's the exact same mechanism that containers such as Flatpak or Docker use to avoid polluting the host OS mount list.) outer$ sudo cryptsetup luksOpen ... myluksvol outer$ sudo unshare --mount --propagation=private su - $USER inner$ sudo mount /dev/mapper/myluksvol ~/mnt (Exiting all processes that are in the namespace will automatically unmount everything that was visible only to that namespace, so mounts will not get "lost".) One problem you will have is that many graphical programs, such as gedit, will start not as child processes of the shell but indirectly as children of your session's dbus-daemon or systemd --user service manager, and will therefore be outside the namespace. (Although gedit specifically has the -s --standalone option to disable this.) To avoid this, you would need to start a whole new D-Bus session bus using dbus-run-session within the shell, but this can have its own problems. (For example, the "dconf" service used by GNOME to serialize writes to the GSettings database assumes that only one instance of the service will be running. Having a second session bus with a second dconf instance might corrupt the GSettings database.)
Securely mount an encrypted container
1,700,951,132,000
I have a luks device and it is opened on boot by /etc/crypttab. lsblk looks like this: sdc 8:32 1 114,6G 0 disk └─luks-672dcc74-d002-47dc-b61b-525baf91dc7c 253:2 0 114,6G 0 crypt I pmount the device like this: pmount /dev/mapper/luks-672dcc74-d002-47dc-b61b-525baf91dc7c I unmount it like this (both work): pumount /dev/mapper/luks-672dcc74-d002-47dc-b61b-525baf91dc7c pumount /media/mapper_luks-672dcc74-d002-47dc-b61b-525baf91dc7c But after pumount lsblk looks like this: sdc 8:32 1 114,6G 0 disk Why did pumount close the luks device? From the man page of pumount it says: Normally, pumount will not luksClose (see cryptsetup(1)) a device pmount did not open. The luks device was opened by /etc/crypttab on boot and not by pmount! Why does pumount close the luks device? Is this a bug? I am on debian bullseye.
Note: I'm completely unfamiliar with pumount, and I don't even have a Debian install available for testing, so I just grabbed the source code from Debian and making wild assumptions based on what I found in there… pumount has an option, --luks-force to close LUKS devices it did not open (as you already quoted from the manpage). However from the source code, there seems to be a mistake in the implementation. So in pumount.c there is this bit of option parsing: int luks_force = 0; [...] { "luks-force", 0, NULL, 'L'}, [...] case 'L': luks_force = 1; break; ...and that's it! The option sets the luks_force = 1 variable. Otherwise it's initialized as 0. But it doesn't matter one bit at all since... that variable isn't used anywhere. In luks.c there is this bit of code: void luks_release( const char* device, int force ) { if(force || luks_has_lockfile(device)) { spawnl( CRYPTSETUP_SPAWN_OPTIONS, CRYPTSETUP, CRYPTSETUP, "luksClose", device, NULL ); luks_remove_lockfile(device); [...] So it will luksClose if either a lockfile is present, or if force is true. And this function is called by pumount.c like this: /* release LUKS device, if appropriate */ luks_release( device, 1 ); So there you go, no matter what you do, force is always set to 1, and so it closes the LUKS device. That last line is probably where it should be using the luks_force variable instead of 1.
Why does pumount close a luks device it did not open?
1,700,951,132,000
I want to add encrypted swap file in FreeBSD 13. I have read this documentation page, but it doesn't explain how to set up encryption for the swap file. I've also read another one, but it only gives examples for encrypted swap partitions, not swap file. The aim is to have encrypted swap file activated on system startup. The system runs latest FreeBSD 13. Please explain how to achieve this.
The link provided by @r bert is close, but could benefit from a little fine-tuning. Credit to original creator mb2015 on the FreeBSD forum. This method creates a custom service script and establishes controlling parameters in /etc/rc.conf. To begin, create /usr/local/etc/rc.d/encrypted_swapfile by copying and pasting this large cat command to execute it, and execute the chmod command following it: # cat << 'EOF' > /usr/local/etc/rc.d/encrypted_swapfile #!/bin/sh # PROVIDE: encrypted_swapfile # REQUIRE: swaplate # BEFORE: LOGIN # KEYWORD: nojail shutdown . /etc/rc.subr name="encrypted_swapfile" rcvar="encrypted_swapfile_enable" start_cmd="${name}_start" stop_cmd="${name}_stop" load_rc_config "$name" : ${encrypted_swapfile_enable:="NO"} : ${encrypted_swapfile_file:="/usr/swap0"} : ${encrypted_swapfile_size:="2G"} SWFILE="$encrypted_swapfile_file"; SWFILEDIR="$(dirname "$SWFILE")"; SWDEVLINK="/var/run/encrypted_swapfile_device"; encrypted_swapfile_start() { # Create and mount a one-time encrypted swap file. # This is a workaround for the inability to do this via an /etc/fstab entry. # See https://forums.freebsd.org/threads/encrypt-swap-file.44519/#post-292933 # if [ ! -e "$SWDEVLINK" ]; then if [ -w "$SWFILEDIR" ]; then truncate -s "$encrypted_swapfile_size" "$encrypted_swapfile_file" && chmod 0600 "$encrypted_swapfile_file" && SWMD="$(mdconfig -a -t vnode -f "$encrypted_swapfile_file")" && if [ $? -eq 0 ] && [ -n $SWMD ] && [ -e "/dev/$SWMD" ]; then chmod 0600 "/dev/$SWMD" && geli onetime -e AES-XTS -l 256 -d "/dev/$SWMD" && chmod 0600 "/dev/$SWMD.eli" && swapon "/dev/$SWMD.eli" && ln -f -s "/dev/$SWMD.eli" "$SWDEVLINK"; unset SWMD; fi else echo "Could not create encrypted swap file in $SWFILEDIR; check permissions." && return 1; fi else SWMD="$(readlink "$SWDEVLINK")" && swapinfo | grep -vq "^$SWMD " && echo "Encrypted swap file already exists; enabling." && swapon "$SWMD"; unset SWMD; fi return 0; } encrypted_swapfile_stop() { if [ -e "$SWDEVLINK" ]; then SWMD=$(readlink "$SWDEVLINK") && swapoff "$SWDEVLINK" && mdconfig -du "${SWMD%.eli}" && rm "$SWDEVLINK" && rm "$SWFILE"; else echo "No encrypted swap file found; nothing to stop."; rm -f "$SWDEVLINK"; fi } run_rc_command "$1" EOF # chmod 755 /usr/local/etc/rc.d/encrypted_swapfile Next, edit /etc/rc.conf to enable this new service, and configure the variables it uses: encrypted_swapfile_enable="yes" encrypted_swapfile_file="/usr/swap0" encrypted_swapfile_size="2G" Now your encrypted swapfile can be activated or deactivated by starting or stopping the encrypted_swapfile service, respectively: # swapinfo Device 1024-blocks Used Avail Capacity # service encrypted_swapfile start # swapinfo Device 1024-blocks Used Avail Capacity /dev/md0.eli 2097152 0 2097152 0% # service encrypted_swapfile stop # swapinfo Device 1024-blocks Used Avail Capacity
How to add encrypted swap file on FreeBSD 13
1,700,951,132,000
I am currently trying to automate the encryption and decryption of a collection of files. For the encryption I currently use: gpg --batch --recipient [RECIPIENT] --encrypt-files [FILES] For the decryption I use pretty much the same: gpg --batch --decrypt-files [FILES] But both during encryption as well as decryption the original file permissions are lost: $ gpg --batch --recipient aram --encrypt-files foo $ ls -l foo* -rw------- 1 aram aram foo -rw-r--r-- 1 aram aram foo.gpg $ rm foo && gpg --batch --decrypt-files foo $ ls -l foo* -rw-r--r-- 1 aram aram foo -rw-r--r-- 1 aram aram foo.gpg I am OK with it during encryption, I can set the file permissions manually. But during decryption, as well as posing a security risk, some files like ssh keys use functionality without proper permissions. Is there a mechanism that retains file permissions during batch decryption? Of course I can loop over the files, read the permission, decrypt and then set the permissions again. But that kind of defeats the point of batch decrypting. There is an open issue on gnupg.org that's 4 years old now and hasn't had much activity since then: https://dev.gnupg.org/T2945
As @a-b and @frostschutz suggested, wrapping the files in a tar file and then encrypting is an option. However, I would like to have access to the original file structure without decrypting. For now, I have resorted to aligning the file permissions after the batch decryption. This has the additional benefit of aligning permissions when the decrypted files are already lying around on disk: gpg --batch --decrypt-files $files for encrypted in $files ; do decrypted=${encrypted%.gpg} chmod --reference="$encrypted" -- "$decrypted" done Of course, the alignment can also be done after each decrypted file: for encrypted in $files ; do gpg --decrypt-files "$encrypted" decrypted=${encrypted%.gpg} chmod --reference="$encrypted" -- "$decrypted" done If you want to be absolutely sure that the decrypted file never has more permissions than the encrypted file, you can use a temporary dummy file and force gpg to overwrite it: for encrypted in $files ; do decrypted=${encrypted%.gpg} touch "$decrypted" && chmod --reference="$encrypted" -- "$decrypted" gpg --yes --decrypt-files "$encrypted" done The same mechanism can be used for aligning permissions after encryption. I have not done any performance testing, not sure if one of the options is faster. I will not accept this as an answer right away, maybe somebody comes up with a better solution than this.
How do I decrypt files with gpg / gnupg without loosing the original file permissions?
1,700,951,132,000
I'm trying to open a bitlocker encryptet partition (/dev/nvme0n1p2) with cryptsetup, but it always returns the following error: # cryptsetup -v open --type bitlk /dev/nvme0n1p2 crypt0 Enter passphrase for /dev/nvme0n1p2: Command failed with code -1 (wrong or missing parameters). The partition uses a clear encryption key and it works with dislocker # dislocker -v /dev/nvme0n1p2 /mnt # ls -lh /mnt total 0 -rw-rw-rw- 1 root root 94G Jan 1 1970 dislocker-file # cryptsetup -v bitlkDump /dev/nvme0n1p2 Info for BITLK device /dev/nvme0n1p2. Version: 2 GUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Sector size: 512 [bytes] Created: Sun Jan 19 17:59:34 2020 Description: (null) Cipher name: aes Cipher mode: xts-plain64 Cipher key: 128 bits Keyslots: 0: VMK GUID: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Protection: VMK protected with clear key Salt: 00000000000000000000000000000000 Key data size: 44 [bytes] 1: FVEK Key data size: 44 [bytes] Metadata segments: 0: FVE metadata area Offset: 49283072 [bytes] Size: 65536 [bytes] 1: FVE metadata area Offset: 1635188736 [bytes] Size: 65536 [bytes] 2: FVE metadata area Offset: 3319005184 [bytes] Size: 65536 [bytes] 3: Volume header Offset: 111169536 [bytes] Size: 8192 [bytes] Cipher: aes-xts-plain64 Command successful. (I removed the GUIDs) Versions: # cryptsetup -v --version cryptsetup 2.3.4 # dislocker -vh dislocker by Romain Coltel, v0.7.1 (compiled for Linux/x86_64) Compiled version: master:dcc08b5
cryptsetup currently doesn't support unlocking BitLocker devices with a clear key. So you'll need to use dislocker with this device. There is unfortunately still a lot of BitLocker features we don't support in cryptsetup. Feel free to report an RFE issue on cryptsetup GitLab. (Btw. It's weird, it doesn't show the correct error message, it should say: Activation of partially decrypted BITLK device is not supported. I should spend less time here and more time fixing bugs :-)
can't open bitlocker encrypted devices with a clear key with cryptsetup but it works with dislocker
1,592,400,743,000
I plan to provide a Linux appliance to several users. These users are tech savvy and can easily reset the root password on a standard linux system. How can I create a running Linux system that keeps even the root user out of the filesystem once protected? (I looked at disk encryption like LUKS but in all cases the root user can gain access to an automounted partition). How do I solve this problem? Stack exchange questions like this assume the attacker does NOT have root access, but it seems simple to reset root password by booting into single user/recovery mode. I've read about LUKS but FDE requires rolling the keyfile into the initramfs (as shown here) but I think you can easily unroll the initramfs and extract the key. So I don't think this solves the problem
I found the answer: encrypt the full disk with LUKS, then store the keys in the system TPM. That way the entire disk is encrypted and an end user can't extract the keys from the TPM...very secure: LUKS with TPM
Protecting (encrypting) system from even root access
1,592,400,743,000
Is there any tools to encrypt folder except encfs for debian?
cryptsetup can be used; MOUNT_NAME=example cryptsetup luksOpen /path/to/file "$MOUNT_NAME" mount "/dev/mapper/$MOUNT_NAME" /path/to/mount encfs encrypts per file disadvantage: attackers know your file sizes, layout, modification time etc. advantage: no need to grow or shrink your container cryptsetup encrypts per mount point disadvantage: one needs to manage the container size advantage: 100% encrypted... and some technical stuff about roiling ciphers
Tools to lock/encrypt folder in debian
1,592,400,743,000
I have a large folder encrypted with eCryptfs and synced with Dropbox. Is somehow possibile to migrate it to EncFS without re-encrypting it and thus without re-upload it to Dropbox?
No. Encfs and Ecryptfs use different format. The only way to convert between them is to decrypt one and encrypt for the other.
How to migrate a folder encrypted with eCryptfs to EncFS
1,592,400,743,000
I know. Tails itself is a very secure operating system, but what about its drive encryption? I would like to encrypt my flash drive with the tails built in drive encryption. What does it use? AES-256?
As explained in the documentation, Tails uses dm-crypt through its LUKS front-end. This is the standard for disk encryption under Linux. LUKS offers a choice of ciphers; the defaults are good (AES-256, CBC or XTS depending on the version, PBKDF2 for password hashing).
How Secure Is Tails Encryption? [closed]
1,592,400,743,000
I need to install the package loop-aes-utils on Debian 8.0 to following this Ubuntu tutorial. It is not in Debian official package however. Would it be the aespipe package or is it another package? # apt-cache search aes | grep loop aespipe - AES-encryption tool with loop-AES support My sources.list file: # /etc/apt/sources.list deb tor+http://ftp.us.debian.org/debian/ jessie main contrib deb tor+http://security.debian.org/ jessie/updates main contrib
loop-aes-utils is obsolete and was removed in 2012. You should use cryptsetup instead, as described in the “Encryption with dm_crypt” section at the start of the tutorial you're following.
Cannot install loop-aes-utils on debian 8.0
1,592,400,743,000
Situation: I am on Debian 8.5. I installed VirtualBox 5.0.22 and its Extension Pack. I further encrypted the VM via VirtualBox: VM settings -> General -> Encryption -> Enable Encryption. Question: How to start and stop the encrypted VirtualBox VM from terminal in headless mode?
To start the VM in headless mode with password, you need to create a file containing the password, suppose: /home/user/vmname-password Then you need to execute the two following commands: VBoxManage startvm "vmname" --type headless VBoxManage controlvm "vmname" addencpassword "vmname" "/home/user/vm-name-password" This is just an example. In real world consider wisely if you wish to expose your VM disk password in a permanently stored file. This Q&A is not about that. To stop the VM: VBoxManage controlvm "vmname" acpipowerbutton
How to start an encrypted VirtualBox VM from terminal in headless mode
1,592,400,743,000
I was thinking about having an encrypted USB flash memory where I would store some passwords and that kind of information. I want it to be encrypted just in case I lose it and someone finds it. I was wondering if it's possible to "encrypt" using public keys like in SSH. I don't know if it would be called encryption but the idea would be that the only way to access to the files in the USB is having the key in your computer (just like as in SSH). In case that's not possible, encrypting a single file with the same idea, would do it.
You can use gpg for asymmetric encryption. Basically you do the following (after you generated a gpg key): $ gpg -ea -r [email protected] file.ext This will create an encrypted file called file.ext.asc in your current directory (-r specifies the recipient, in this case that's you). To decrypt do the following $ gpg -d file.ext.asc > file.asc You need a passphrase to unlock the secret key for user: "Real Name (Comment) <[email protected]>" 2048-bit ELG-E key, ID 7F72A50F, created 2007-12-01 (main key ID 9B1386E2) Enter passphrase: (source). If you want to use this on file system level, you can combine this with the other answer. Generate a random key: $ dd if=/dev/urandom of=random-key count=1024 $ gpg -ea -r [email protected] random-key and use the following to create and unlock your file system $ gpg -d random-key.asc | cryptsetup luksFormat /dev/sdXY -d - $ gpg -d random-key.asc | cryptsetup luksOpen /dev/sdXY usbstick -d - -d is shorthand for --key-file. Disclaimer: Those commands are untested. Read yourself into gpg first and try this without important data!
Encrypted USB with SSH keys system
1,592,400,743,000
I have to encrypt a hash, eg: 2c1400f69867571ab4e60d3b8f01e0b17c7be89e321f91f8a07cd39eeba202e2 using the RSA algorithm by using a public key(eg: mykey.key) that was already provided to me. How do I go about doing this. I see sites telling me to use openssl, but I'm not sure how to go about this. EDIT : I tried doing this I created a file and push the hash in it by doing this echo "2c1400f69867571ab4e60d3b8f01e0b17c7be89e321f91f8a07cd39eeba202e2" >file.txt then followed by this openssl rsautl -inkey mykey.key -pubin -encrypt -in file.txt > file.txt.enc when I tried to open file.txt.enc on notepad, i got this: Not sure if this is a successful encryption as I need the ciphertext result in binary format.
Try: $ cat file.txt | openssl rsautl -encrypt -pubin -inkey mykey.key > secret.txt cat secret.txt }[4�Or)f���r�_ # more binary data here... and then: $ cat secret.txt | openssl rsautl -decrypt -inkey myprivatekey.key 2c1400f69867571ab4e60d3b8f01e0b17c7be89e321f91f8a07cd39eeba202e2 Both keys should be in PEM format.
Encrypt a hash using RSA
1,592,400,743,000
I was about to backup my archlinux, following this guide to my FritzBox, (which enforces a NTFS system that I mounted via samba) as I remembered, that NTFS is not capable to keep permissions and other stuff like symlinks. There is also no encryption available which is really bad because it would break the idea to encrypt my laptop :) So I was wondering if there is a method which can do incremental backups like rsync but creates something like an encrypted tarball 'on the fly'?
I would mount ecryptfs on the ntfs filesystem and still use rsync - as long as you don't need to read the files from windows. Just watch out for long path names as you might hit some trouble: http://www.telmon.org/?p=631 As a side note, I haven't tried this but the encfs4win project looks good if you need access from windows as well: http://members.ferrara.linux.it/freddy77/encfs.html
backup / on ntfs filesystem encrypted
1,592,400,743,000
Which package contains the implementation of IPsec and which package contains the implementation of encryption algorithms that IPsec uses for encryption? I need to use custom crytographic algorithms in IPsec, so I need to edit the implementations of these packages.
On Linux and most other unices, IPsec and other network protocols up to the transport layer are implemented in the kernel. There are additional userland tools that handle key exchange; several implementations exist. The cryptographic algorithms are in crypto. The network protocols are spread around net/ipv4, net/ipv6 and net/xfrm.
Which packages contain IPsec implementations and algorithms that use it for encryption?
1,592,400,743,000
I need to convert my /etc/password file into /etc/shadow. I found this command for manually generating password in shadow. openssl passwd -6 -salt xyz yourpass but I need to convert my /etc/password to /etc/shadow, is there any command for that?
Yes, there is. Read man pwconv.
is there any command which converts my etc/password/ file into etc/shadow/ file?
1,592,400,743,000
I have a need to securely transmit data between two endpoints via rsync. This is illustrated in the diagram. My client wants me to use a VPN connection, as the VPN server already exists and is used as a jump server to access the application environment. Plus they regard a VPN as more secure than using ssh, as the end App Server is not directly accessible from the Internet so that would be a significant change to their environment. I understand that the rsync daemon (rsyncd) is usually used with rsync over a VPN, to avoid the performance hit double encryption (VPN and ssh) would involve; there is a large amount of data to transmit and only a weekend to do it in so this is a real concern. However I have also been asked to ensure that the transmission is encrypted end-to-end, even between the VPN server and the receiving node, which is something that I believe only ssh, not rsh or rsyncd could provide? Using the VPN server as a staging server is not an option either. So, am I stuck with VPN + ssh here as a solution, or is there something I'm missing that could help? Both the VPN server and App Server are in AWS if that makes any difference?
If you really want to avoid something between the VPN endpoint and the far end sniffing your rsync, then yes you need to wrap it in another layer terminated only by the far end. SSH is one option for that; stunnel might be another if you have enough control over the process.
rsync end-to-end encryption when using a VPN?