date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,468,835,896,000 |
I cannot connect to my Fedora 31 Workstation GUI via "Screen Sharing" from any other (non-Linux) machine. I am almost certain this is due to the encryption that the VNC server for "Screen Sharing" is using. However, I am behind the firewall on my LAN and do not need external access whatsoever, so I do not need encryption. I know for sure that SS does work because when I test it from my Ubuntu machine with Remmina, it works as expected. However, I tested all of these VNC clients on Win/Mac and they do not work:
uVNC client
RealVNC Viewer (aka VNC Connect)
Default "Screen Sharing.app" on macOS
How can I disable the encryption that the "Screen Sharing" VNC server uses so that I can connect from a Windows or Mac machine?
EDIT: The solutions here worked to allow VNC to connect!
gsettings set org.gnome.desktop.remote-desktop.vnc encryption "['none']"
sudo firewall-cmd --permanent --add-service=vnc-server
sudo firewall-cmd --reload
sudo reboot now
However, the screen resolution is strange and tripled - any how to fix this?
|
Running these commands disabled VNC encryption and allows the connection to work on Fedora 31:
gsettings set org.gnome.desktop.remote-desktop.vnc encryption "['none']"
sudo firewall-cmd --permanent --add-service=vnc-server
sudo firewall-cmd --reload
#finally, reboot the machine/VM
sudo reboot now
| How can I disable VNC encryption in default/built-in "Screen Sharing" on Fedora 31 Desktop? |
1,468,835,896,000 |
I am using rdesktop on a Fedora laptop to connect to Windows computers at work. To make it easier, I've made an alias in my .bashrc:
alias companyremote='rdesktop -u USER -p - -g 1920x1040 -K'
So I just have to type
companyremote NAME
to connect to a given computer. But I don't want to store my passwords in plaintext in my .bashrc, so I have to type the password every time in standard input. I'd rather have a clean command with no other required input that only requires me to be a certain user.
I suppose the VPN connection is the primary security layer, not the actual Windows password, but I'd rather be safe than not, and why not learn something?
How can I store an encrypted password that I can use with an alias like this?
|
A password agent (also known as a keychain/keyring or secrets store) is the tool for this. The idea is to keep all your passwords in an encrypted database protected by a master password. The agent starts when you log in, gets the master password from you, then decrypts individual passwords for other programs on request. Often the master password will be the same as your login password, in which case the agent gets the password automatically when you log in.
If you've got the Gnome-keyring password agent running, you can use the secret-tool command-line client to look up passwords and pipe them into rdesktop.
Since Gnome-keyring is designed to store a lot of passwords, it needs to tell them apart, so it stores identifying information with each password in the form of a set of attributes and values. These can be anything, but no two passwords can have the exact same set of identifiers. For remote Windows login, useful identifiers might be "user" and "domain", or "user" and "hostname". It also stores a label, which is for humans to tell the password entries apart.
$ secret-tool store --label "jander@mydomain" user "jander" domain "mydomain"
Password:
Then, you can use something like the following to start rdesktop:
$ secret-tool lookup user "jander" domain "mydomain.com" | rdesktop -d "mydomain" -u "jander" -p - remotehost.mydomain
The seahorse GUI tool is useful for inspecting your keychains, locking and unlocking them manually, and changing passwords. It's not great for adding passwords, though, since it doesn't provide any way to set identifiers.
For more technical details you might be interested in the Freedesktop.org secret storage spec, which Gnome-keyring implements.
Finally, keep in mind that when you use an agent, you are giving up security for convenience: anyone who can sit down at your laptop while you're logged in can now also log into your remote desktop without knowing the password. You'll probably want to use a locking screensaver at a minimum.
| How can I store an encrypted rdesktop password for easier sign-in? |
1,468,835,896,000 |
my girlfriend bought Lenovo Essential G500 i5-3230 and I installed Linux Mint 16 on it with full disk encryption. It is standard installation with encryption using dmcrypt and LUKS. But there is a problem with screen brightness, it is set to 0 before it even ask for password to encrypted partitions. I partly fixed it by adding:
echo 50 > /sys/class/backlight/acpi_video0/brightness
to /etc/rc.local but it fixes brightness after typing correct password to mount encrypted partitions. I want to fix brightness before that, so I can see the password input field. /etc/rc.local is loaded after mounting encrypted disk so I think I need to somehow force kernel to change brightness just after it loads itself and before mounting.
Is there a way to tell kernel to adjust brightness just after boot?
Graphic cards on laptop are: AMD® Radeon HD 8570M + Intel HD Graphics 4000
UPDATE
I've tried solution sugested by @derobert. I created initramfs script /etc/initramfs-tools/scripts/init-premount/local-backlight-brightness
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
echo 50 > /sys/class/backlight/acpi_video0/brightness
And after this:
$ sudo chmod a+rx /etc/initramfs-tools/scripts/init-premount/local-backlight-brightness
$ sudo update-initramfs -u
$ sudo reboot
But it don't work, screen is almost black when asking for password. I'm not even sure if this script was executed. How can I check if it was executed? Maybe I should add some requirements in PREREQ="" to make it work?
UPDATE 2 FINALLY WORKING
Ok, I decided to read manual for initramfs-tools again to check if everything was good and it looks like I used wrong boilerplate for my script. The correct one is:
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
# Begin real processing below this line
echo 50 > /sys/class/backlight/acpi_video0/brightness
The problem was with . /usr/share/initramfs-tools/hook-functions. This line was used for hook scripts that are not included in intramfs image. It should be . /scripts/functions. After changing it, brightness works like I wanted.
I'm marking @derobert answer as correct because it directed me to correct solution.
|
You need to add that script to your initramfs. On Debian (I suspect Mint is the same), it appears that the password prompt comes from /usr/share/initramfs-tools/scripts/local-top/cryptroot. That script arranges itself to be called last out of the local-top scripts. There is a parallel set of directories in /etc intended for local customization. So you just need to plop a file that looks something like:
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
echo 50 > /sys/class/backlight/acpi_video0/brightness
into either /etc/initramfs-tools/scripts/local-top or /etc/initramfs-tools/scripts/init-premount. The file name doesn't matter, though I'd pick something like local-backlight-brightness to make sure it doesn't conflict with some package-provided script. (The prereqs boilerplate comes straight from the initramfs-tools manpage.)
Then, run update-initramfs -u.
| How to set laptop screen brightness just after boot with full disk encryption |
1,468,835,896,000 |
I received an file encrypted with the public key I generated but I can't get it to decrypt.
Steps:
gpg --gen-key default options
gpg --export -a <email> > pub.key
sent the pub.key
received the encrypted file
cat <file> | gpg
The error:
$ cat cred.gpg | gpg
gpg: key 71980D35: secret key without public key - skipped
gpg: encrypted with RSA key, ID 0D54A10A
gpg: decryption failed: secret key not available
However, the secret key DOES exist in my keyring and the public key i generate from it matches the fingerprint of the pub.key i sent to my coworker.
$ gpg --list-secret-keys
/home/jcope/.gnupg/secring.gpg
------------------------------
sec 2048R/71980D35 2016-03-04
uid me <email>
ssb 2048R/0D54A10A 2016-03-04
Checking the fingerprint
$ gpg --with-fingerprint pub.key
pub 2048R/AF0A97C5 2016-03-04 me <email>
Key fingerprint = 17A4 63BF 5A7D D3B2 C10F 15C0 EDD6 4D8A AF0A 97C5
sub 2048R/1103CA7C 2016-03-04
$ gpg --fingerprint | grep 17a4 -i
Key fingerprint = 17A4 63BF 5A7D D3B2 C10F 15C0 EDD6 4D8A AF0A 97C5
I'm a gpg newby and at a loss for why this isn't working. It seems like the most standard operation.
|
Note the error message: it doesn't say that the secret key is missing (it isn't), it says the public key is missing.
gpg: key 71980D35:secret key without public key- skipped
In RSA, some numbers (d, p, q, u) are private and others (n, e) are public. Only the 2 public numbers are required for encryption and signature verification while all 6 numbers are required in order to decrypt and sign. So for the latter operations, you actually need both the secret and public keys.
Did the public key get deleted from the pubring by accident?
You can try re-importing the public key. Since the public key is the one that is distributed widely, it should be easy to re-obtain a copy of it.
| gpg: "secret key not available" when sec & pub key are in keyring |
1,468,835,896,000 |
I want to block any kind of access to a certain directory unless a password is provided. It could be my root or account password.
The directory is residing on an NTFS partition, and this method needs to work for Windows as well, as I'm accessing the partition from both Linux and Windows interchangeably.
It could be implemented as encryption.
How do I achieve this?
|
TrueCrypt, or another encryption method, is probably the way to go with this.
| How to lock a directory? |
1,468,835,896,000 |
I was looking at dm-crypt and have seen that you can use whatever filesystem you like on top of the encrypted drive. So I was wondering if a journaled filesystem is a good idea as opposed to a non-journaled one. Also, what filesystem would be best to deal with power failures with an encrypted drive?
|
Journaling is a technique that helps with recovery from problems that occur when multi-write operations are interrupted. Such interruptions can leave the file system in an inconsistent state between writes.
Interruptions can happen with "normal" block devices and dm-crypt block devices alike. For a file system, a block device is a block device. Block device encryption and file system journaling are completely separate concerns.
| Is a journaling filesystem a good idea with a dm-crypt encrypted drive? |
1,468,835,896,000 |
I want to use GPG for local encryption only, and after reading the man file, I'm doing the following in order to encrypt a whole directory:
I zip the directory with a password "zip -r -e foo foo", then I encrypt it with "gpg -c foo.zip" using a passphrase. Is this an elegant and secure way of encrypting directories? Am I using GPG's full cryptographic power? Are there better alternatives?
So there's no a way to encrypt a whole directory without zip it or tar it?
|
Is this an elegant and secure way of encrypting directories?
Elegant -- no. Secure -- as secure as gpg.
Am I using GPG's full cryptographic power?
Yes.
Are there better alternatives?
tar the directory first instead of zip. gpg compresses data anyway.
| Encrypting directories with gpg [duplicate] |
1,468,835,896,000 |
Can I decrypt an ecryptfs Private directory from a script?
My basic use case for this type of activity is for doing remote backups. Imagine you have a machine (call it privatebox) with an encrypted private directory that stores your photos (or some other sensitive information). It is only decrypted upon logging in. And imagine that you want to be able to write a script on a remote machine that will log into the privatebox, decrypt the directory to add a photo, then re-encrypt it and log out. All without user interactive steps being required (maybe it runs from cron). Note that the passphrase for the privatebox would NOT be stored on the privatebox in plain text or anything. And since it would be encrypted (except during the update) it would be protected if someone obtained the SD card, etc.
Such a script would work like this (in my mind):
setup private directory on privatebox that is encrypted with a passphrase
setup ssh keys from local machine to privatebox so you can use ssh non-interactively (cron can login)
Then what? How do you decrypt a private folder non-interactively if you know the passphrase?
It seems that ecryptfs is specifically designed to not allow this (even with SSH key trickery, you still have to manually mount your private directory).
Basically, what I'm looking for is a non-interactive version of 'ecryptfs-mount-private' or something similar if anyone knows a solution. Something like:
% ecryptfs-mount-private -p $PASSPHRASE
Where I could pass the passphrase instead of having to type it.
If ecryptfs can't do this, does anyone know of an alternative? Thanks!
|
Okay I figured this out. Thanks for your help Xen2050, I don't have enough reputation here to give you an upvote (yet).
Here's the bash script that works for me:
#Set this variable to your mount passphrase. Ideally you'd get this from $1 input so that the actual value isn't stored in bash script. That would defeat the purpose.
mountphrase='YOURMOUNTPASSPHRASE'
#Add tokens into user session keyring
printf "%s" "${mountphrase}" | ecryptfs-add-passphrase > tmp.txt
#Now get the signature from the output of the above command
sig=`tail -1 tmp.txt | awk '{print $6}' | sed 's/\[//g' | sed 's/\]//g'`
rm -f tmp.txt #Remove temp file
#Now perform the mount
sudo mount -t ecryptfs -o key=passphrase:passphrase_passwd=${mountphrase},no_sig_cache=yes,verbose=no,ecryptfs_sig=${sig},ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=no /home/user/.Private /home/user/Private
Note that I had to disable filename encryption for this to work. When I tried using filename encryption I got a library error during the mount. In order to not have filename encryption, you must use the following when creating your Private/ directory:
ecryptfs-setup-private -n
This is now working for me.
In response to some people who would say 'why do it this way?', well, I don't always want to mount my private data on each login. I want to have a quick way of mounting the data that does not require me to use my actual user login password. Imagine I want to share the data with someone else? I would have to give them my password. Using the mount passphrase allows me to have essentially a mount password that can be less secure than my login. This is also useful if you want to automount your data and store the phrase somewhere (perhaps on a USB stick as a key to unlock your data). I would never want to store my login password anywhere in plain text. But if you know the content of your data, and you know the data itself is less private than your own account, this is an fine solution.
| Non-interactive ecryptfs directory encrypt/decrypt |
1,468,835,896,000 |
Is there a command to extract information about the algorithm that is used (RSA, ECDSA, 3DES ...) for SSH keys, regardless of the format (pem, der etc)?
I looked into openssl, but I could not find anything about this.
|
You can use next command to get the type of the key (RSA, DSA, etc):
# ssh-keygen -l -f .ssh/id_rsa
2048 SHA256:4+Na0ttfBkspSFSYnRjwbwja8/b708lRxzqjPBzLJMw ........ (RSA)
# ssh-keygen -l -f .ssh/id_dsa
1024 SHA256:F6h53Zu0A9M094CbszkwxfQ5L2EZ0kUEpLkH0dp1alU ........ (DSA)
# ssh-keygen -l -f .ssh/id_ed25519
256 SHA256:b4mTk5rvo0SgazbzQxame6gX7r1MPtXeGNJY2q4Y3dg ........ (ED25519)
In the command you can specify file the private or the public key
| Extract ssh key algorithm |
1,468,835,896,000 |
I need to encrypt and be able to decrypt files with openssl, currently I do this simply with:
openssl enc -aes-256-cbc -salt -in "$input_filename" -out "$output_filename"
and the decryption with:
openssl enc -aes-256-cbc -d -salt -in "$input_filename" -out "$output_filename"
But with large files, I would like to see progress.
I tried different variations of the following (decryption):
pv "$input_filename" | openssl enc -aes-256-cbc -d -salt | pv > "$output_filename"
But this fails to ask me for a password. I am unsure as to how to go about it?
EDIT1:
I found this tar over openssl:
https://stackoverflow.com/a/24704457/1997354
While it could be extremely helpful, I don't get it much.
EDIT2:
Regarding the named pipe:
It almost works. Except for the blinking progress, which I can't show you obviously and the final result looking like this:
enter aes-256-cbc decryption password:
1.25GiB 0:00:16 [75.9MiB/s] [==============================================================================================================================================================================================>] 100%
1.25GiB 0:00:10 [ 126MiB/s] [ <=> ]
|
You should try
openssl enc -aes-256-cbc -d -salt -in "$input_filename" | pv -W >> "$output_filename"
From the Manual:
-W, --wait:
Wait until the first byte has been transferred before showing any progress information or calculating any ETAs. Useful if the program you are piping to or from requires extra information before it starts, eg piping data into gpg(1) or mcrypt(1) which require a passphrase before data can be processed.
which is exactly your case. If you need to see the progress bar, for the reason clearly explained by Weijun Zhou in a comment below, you can reverse the order of the commands in the pipe:
pv -W "$input_filename" | openssl enc -aes-256-cbc -d -salt -out "$output_filename"
| How to use pv to show progress of openssl encryption / decryption? |
1,468,835,896,000 |
I read a lot of articles about using gpg to encrypt email, but I would like to use it to encrypt some files - mainly a bunch of *.isos. I'm going to describe what I thought I would do, so you can shoot me or just add some suggestions.
I'm going to do
tar -cvjf myiso.iso.tar.bz2 myiso.iso
and them I plan to encrypt this myisio.tar.bz2, using a key generated by gpg (don't know exactly how to do that. I'm going to read the man page). Them, I'm going to save this generated gpg key I used for this encryption in a flash drive, and encode this key itself with a symetric key.
Is it to insane?
|
You can use GPG to symmetrically encrypt a file with a passphrase (gpg -c). If the passphrase has enough entropy, you don't need an extra step of generating a secret key. What does “enough entropy” mean? Your encryption needs to withstand offline attacks, where the attacker can make cracking attempts as fast as his hardware allows it. With a small PC farm, the attacker might be able to make a couple hundred billion attempts per second, which is roughly 2^69 per decade. So with an entropy of 2^70 you'll be safe. That means if your passphrase consists of completely random letters (lower or upper case) and digits, it should be 12 characters long.
Now to store that passphrase, you can use GPG with its usual key pairs. Use gpg --gen-key to generate a key pair, and gpg -e to encrypt the passphrase used to encrypt the large file for one or more key pairs.
Here's a sketch on how to do the encryption (note that I avoid putting the passphrase on the command line or in the environment, so as to make sure another user can't find it by looking at the ps output while the command is running):
passphrase=$(pwgen -s 12 -1)
echo "The passphrase for myiso.iso.gpg is: $passphrase" |
gpg -e -r somebody -r somebodyelse >passphrase.gpg
echo "$passphrase" | gpg -c --passphrase-fd 3 3<&0 <myiso.iso >myiso.iso.gpg
and how to decrypt:
passphrase=$(gpg -d <passphrase.gpg)
echo "$passphrase" | gpg -d --passphrase-fd 3 3<&0 <myiso.iso.gpg >myiso.iso
The reason to use a passphrase (a shared secret) rather than directly encrypt is that it allows the file to be shared between several people. Only the small passphrase needs to be reencrypted if you want to add a recipient (removing a recipient only makes sense if you know the recipient hasn't had access to the plaintext and requires reencoding the ciphertext anyway).
| Encrypt files using gpg (and them symetric encrypting the key) - is it a normal thing to do in the *nix world? |
1,468,835,896,000 |
http://codahale.com/how-to-safely-store-a-password/
with what does OpenBSD store the password by default?
They say bcrypt is way more secure then hashing. I googled' it and obsd supports bcrypt, but does it use it by default?
Thank you!
|
From: http://www.openbsd.org/papers/bcrypt-paper.pdf
We have implemented bcrypt and deployed it as part
of the OpenBSD operating system. Bcrypt has been
the default password scheme since OpenBSD 2.1
| Does OpenBSD use bcrypt by default? |
1,468,835,896,000 |
I've changed my password to X and the shadow file has changed to:
ahmad:$1$oYINSKjP$eCkCtJV/2dXerAD57WQPj/:15425:0:99999:7:::
I see the encrypted X as $1$oYINSKjP$eCkCtJV/2dXerAD57WQPj/. How can I retrieve the encrypted X without changing the password? openssl or any other command to use?
|
Your password isn't encrypted. It is hashed.
A salted MD5 hash has been generated and written to /etc/shadow. You cannot retrieve original value.
The original value X has been hashed in this format: $id$salt$encrypted - id == 1 stands for MD5 (see NOTES on manpage of crypt(3))
| Encrypt word X to /etc/shadow encryption |
1,468,835,896,000 |
I need to send a private key file to someone (a trusted sysadmin) securely. I suggested a couple options, but he replied as follows:
Hi, I don't have neither LastPass nor GnuPGP but I'm using ssl
certificates - this message is signed with such so you will be able to
send a message to me and encrypt it with my public key.
I used openssl to obtain his certificate:
openssl pkcs7 -in smime.p7s -inform DER -print_certs
The certificate is issued by:
issuer=/O=Root CA/OU=http://www.cacert.org/CN=CA Cert Signing Authority/[email protected]
(Firefox doesn't have a root certificate from cacert.org.)
Now, how do I encrypt the key file I wish to send to him? I prefer to use a command line tool available in Ubuntu.
@lgeorget:
$ openssl pkcs7 -inform DER -outform PEM -in smime.p7s -out smime.pem
$ openssl smime -encrypt -text -in /home/myuser/.ssh/mykeyfile smime.pem
unable to load certificate
139709295335072:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: TRUSTED CERTIFICATE
and
$ openssl pkcs7 -in smime.p7s -inform DER -print_certs
subject=/CN=Wojciech Kapcia/[email protected]/[email protected]
issuer=/O=Root CA/OU=http://www.cacert.org/CN=CA Cert Signing Authority/[email protected]
-----BEGIN CERTIFICATE-----
MIIFzjCCA7agAwIBAgIDDR9oMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv
b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ
dEBjYWNlcnQub3JnMB4XDTEzMDQxODA3NDEzNFoXDTE1MDQxODA3NDEzNFowcDEY
MBYGA1UEAxMPV29qY2llY2ggS2FwY2lhMSkwJwYJKoZIhvcNAQkBFhp3b2pjaWVj
[snip]
N1lNLq5jrGhqMzA2ge57cW2eDgCL941kMmIPDUyx+pKAYj1I7IibN3wcP1orOys3
amWMrFRa30LBu6jPYy2TeeoQetKnabefMNE3Jv81gn41mPOs3ToPXEUmYU18VZ75
Efd/qu4SV/3SMdySSNmPAVQdXYAxBEXoN5b5FpUW7KeZnjoX4fkEUPeBnNwcptTC
d1w=
-----END CERTIFICATE-----
|
You can do
openssl smime -encrypt -text -in <file> smime.p7s
where <file> is the file you want to encrypt. If the file smime.p7s is in DER format instead of PEM, you will have to convert it with :
openssl pkcs7 -inform DER -outform PEM -in smime.p7s -out smime.pem
You obtain a file you can send to your sysadmin. If you are brave enough you can remove -text and play with the option -to, -subject, etc. to get a valid email file you can directly send to a SMTP server.
If the root certificate of the certificate you use to encrypt is not recognized by your operating system but YOU trust it, you can add it to the certificate base.
cp smime.pem /usr/local/share/ca-certificates/certificate.crt
sudo update-ca-certificates
The certificate must have the .crt extension. Details here.
| How to encyrpt a message using someone's SSL smime.p7s file |
1,468,835,896,000 |
I am trying to parental control myself by restricting web access via OpenDNS. The OpenDNS account password will be handed to someone trustworthy. Now, I want to put some restriction on the /etc/resolv.conf, perhaps using a key or password, but not the root password. Also I do not want to compromise the accessibility by the kernel. Is this possible?
|
No, not the way you're trying to do it. Root has access to every file on the system. You can make it harder to modify the file (note: it has to be publicly readable), but if you have root access, you can't prevent yourself from modifying it.
There is no password protection feature for files. Even if there was one, being root, you could remove it. (You can encrypt a file, but that makes it unreadable.)
One way to make it harder to modify the file is to set the immutable attribute: chattr +i /etc/resolv.conf. Then the only way to modify it will involve running chattr -i /etc/resolv.conf. (Or going to a lower level and modifying the disk content — with a very high risk of erasing your data if you do it wrong.)
If you want to put a difficult-to-bypass filter on your web browsing, do it in a separate router box. Let someone else configure it and don't let them give you the administrator password.
| Password protecting a system file? (e.g. /etc/resolv.conf) |
1,468,835,896,000 |
I know that GnuPG is all about security, thus it's not giving many chance of retrieve private keys (otherwise anyone could do it) but I've got a private key, and my own rev.asc file.
I had to reinstall my Ubuntu box (former Ubuntu Studio) and I have backup of /home and /etc.
Is it possible to recover my GnuPG key instead of revoke it and create another one?
|
By default, GPG stores everything under the .gnupg directory in your home directory. (Your encrypted private key should be in ~/.gnupg/secring.gpg).
Restoring the entire ~/.gnupg directory from your backup will do the trick.
| How to restore GnuPG key after reinstall? |
1,468,835,896,000 |
If I install Debian, I can choose to set up the disk using an encrypted LVM. But what exactly does this set up? Is just the partition table encrypted, or are all files on all partitions encrypted?
|
When you use this option, the installer creates a few partitions: a /boot partition, which is used to store the kernel and bootloader; depending on your system, a special firmware (e.g., EFI) partition; and an encrypted partition which contains a single LVM physical volume.
Inside that encrypted LVM physical volume, there is a root partition and usually a swap partition, plus any additional partitions you want. All of these partitions are encrypted, but the /boot and /boot/efi partitions are not.
It is never possible to encrypt the EFI partition, since the firmware doesn't know how to boot it in such a state. It is possible, but uncommon, to encrypt the /boot partition; grub requires special configuration to do so, which Debian doesn't implement by default.
| What is an encrypted LVM? |
1,468,835,896,000 |
More recent AMD CPUs have a feature named Secure Memory Encryption SME which if available can be explicitly be enabled by adding this parameter to linux' command line.
mem_encrypt=on
(according to https://libvirt.org/kbase/launch_security_sev.html)
I am unsure if my system (with an AMD EPYC cpu) has this feature enabled (i.e. if the feature might be default on anyway).
My question is how to check if the AMD SME feature is enabled?
Since https://www.kernel.org/doc/html/latest/x86/amd-memory-encryption.html suggests that:
If support for SME is present, MSR 0xc00100010 (MSR_K8_SYSCFG) can be
used to determine if SME is enabled and/or to enable memory
encryption:
I have run this commands (on a debian 10):
apt-get install msr-tools
rdmsr --raw 0xc0010010 | xxd -b
which presented me this output
00000000: 00000000 00000000 11110100 00000000 00000000 00000000 ......
00000006: 00000000 00000000
where according to the source quoted the 23rd bit indicates if SME is indeed enabled/active (=1) or not (=0).
If above is indeed the correct way to test this, a confirmation may be considered a valid answer, ideally of course providing some background.
Else again I would be very happy to be able to check the state of SME on a running linux system.
|
If SME is supported (CPUID shows the corresponding bit set) and enabled (the appropriate MSR bit is set), /proc/cpuinfo will contain the sme flag. You can verify this by looking at the kernel code which detects SME: the SME feature, which is reflected directly in /proc/cpuinfo, is cleared if SME isn’t fully enabled.
You should also see corresponding messages in the kernel boot logs:
AMD Memory Encryption Features active: SME
if SME is active,
AMD Memory Encryption Features active: SEV SEV-ES
if SEV and/or SEV-ES are active.
See also What do the flags in /proc/cpuinfo mean?
| How to know if a AMD cpu's SME feature is enabled? |
1,446,884,727,000 |
In Debian 7 it seems like ssh doesn't accept ed25519 keys.
support for ECDSA was not added until end of 2013, but wheezy is older
How do I enable this in Debian 7?
|
There are updated openssh client and server packages in Wheezy Backports.
According to the changelog, the backported version can work with ED25519 keys:
openssh (1:6.6p1-4~bpo70+1) wheezy-backports; urgency=low
Rebuild for wheezy-backports.
-- Colin Watson Wed, 30 Apr 2014 09:59:29
+0100
[...]
openssh (1:6.5p1-1) unstable; urgency=medium
[...]
Generate ED25519 host keys on fresh installations. Upgraders who
wish
to add such host keys should manually add 'HostKey
/etc/ssh/ssh_host_ed25519_key' to /etc/ssh/sshd_config and run
'ssh-keygen -q -f /etc/ssh/ssh_host_ed25519_key -N "" -t ed25519'.
-- Colin Watson Mon, 10 Feb 2014 14:58:26
+0000
To install wheezy-backports packages, follow the instructions. In short, you need to add the following line to your /etc/apt/sources.list:
deb http://http.debian.net/debian wheezy-backports main
It would be wise to carefully read the backports site before making use of the repo.
| Enable ed25519 in Debian wheezy |
1,446,884,727,000 |
I have full disk encryption on my arch linux laptop. When i power on the machine it prompts me for my disk password. My system is encrypted by following the LVM on luks archwiki page.
the prompt says something like "a password is required for the cryptlvm volume" i would like to change this to feature some imformation about the system like the owner and an address to return it to if lost. So far i have just tried to look at the arch wiki and search to see if anyone else had asked anything similar but i cannot seem to find anything.
|
I found out that that you can make a custom initramfs module with mkinitcpio that prints out such information. Ensure you follow this correctly, otherwise your kernel will panic. To do so, you can create files under:
/usr/lib/initcpio/hooks/MODULENAME
/usr/lib/initcpio/install/MODULENAME
/usr/lib/initcpio/install/MODULENAME
This is a bash script that helps build the module when you regenerate initramfs with mkinitcpio. It must have build() and help() functions. The build function calls an add_runscript command which adds our runtime bash file of the same name under: /usr/lib/initcpio/hooks/MODULENAME.
build() {
add_runscript
}
/usr/lib/initcpio/hooks/MODULENAME
This is a bash script that is run when initramfs is loaded.
Any commands you would like to be run must be in a function called run_hook()
run_hook() {
# note this environment is limited as our drive is encrypted
# only core system commands will be available
# it is possible to add more commands to the initramfs environment
echo "hello!!"
}
Add hook to mkinitcpio.conf
Now we add the hook to the array in our mkinitcpio configuration file located at /etc/mkinitcpio.conf
# we put in the custom hook
# we put it before our encrypt hook!!
# so it shows before our password prompt
HOOKS=(base udev autodetect modconf kms keyboard MODULENAME encrypt lvm2 keymap consolefont block filesystems fsck)
Regenerate mkinitcpio
finally we can regenerate our initramfs so that this module can loaded on next boot.
$~ sudo mkinitcpio -p linux
Check the output for any errors before rebooting to check -- and pray for no kernel panic!
| custom prompt for system encryption password entry on startup |
1,446,884,727,000 |
I am reading the postgresql database documentation, but I can't found nothing about encrypting the database files to prevent someone to see the data without the database password. There is some way to make postgresql safe if someone, for example, get physical access to the server?
I know that Linux can encrypt the partition as said in the documentation, but that is not what I am looking for.
|
To protect your data against physical access to the server, you need to move the encryption/decryption at least partially off the server. If your server can boot and mount its encrypted partitions without external help, then it's vulnerable.
If you only care about physical removal, involving a reboot of the server, then disk encryption might be sufficient, if the encryption key is stored off the server; for example, using network encryption (a key unlocking server somewhere else on the network, for example Tang and Clevis), or as grochmal suggested, a key entered manually at boot (but in the latter case your server won't boot unattended, which could be a significant inconvenience).
If you care about physical access in general, then you should perform the encryption and decryption using information stored on the clients, for example using pgcrypto, or even performing encryption and decryption solely on the clients, coded in your client application. In these cases though the encrypted data is no longer usable in queries, unless you implement homomorphic encryption. There are quite a few subtleties involved, for example with data representation (NULL values in particular), so you should probably talk to a security expert (without re-inventing the wheel...).
| Encrypt postgresql database |
1,446,884,727,000 |
If I only encrypt the home directory, what are some common ways for information to leak out to the unencrypted part of the file system? Aside from the obvious problems like
swap space
files in /tmp
are there any common Linux programs leaking information (those which are nearly certainly part of a normal installation)?
For example something like locate: it leaks all file names to /var/lib/mlocate/mlocate.db and is even part of a minimal Debian or Arch Linux installation.
|
Aside from home directories, there are three directory hierarchies with writable data: /etc, /tmp and /var.
/etc contains system configuration files, most of which are typically not sensitive. But there can be sensitive data there, e.g. wifi passwords.
/tmp can potentially contain sensitive data; just about any program might put temporary files there. This is easily dealt with by making it an in-memory filesystem (tmpfs). This way, if its content ever ends up on disk, it'll be in swap, which has to be encrypted if you care about encrypting anything.
/var has many subdirectories. In particular:
/var/tmp is like /tmp, but it's supposed to be on-disk. Few programs write there, but when it's used at all, it's usually for large files. It's difficult to predict who's going to need it, so it should be encrypted.
/var/mail (or /var/spool/mail) may end up containing sensitive data, or it may not. It depends how you use local mail and whether error messages from cron job may contain sensitive data.
/var/spool/cups or /var/spool/lp (or a few other variations) contain temporary files during printing. If you ever print confidential documents, this should be encrypted as well.
Other directories in /var/spool may contain sensitive data, such as outgoing emails.
Sensitive information can end up in system logs in /var/log.
As you noted, if you have sensitive file names, they may end up in /var/cache/locate or /var/lib/mlocate or variations on that theme.
If you want peace of mind, just encrypt everything except /boot. Nowadays most computers are powerful enough that the cost of encryption on the CPU is negligible, and most distributions support whole-disk encryption easily.
| Information leaks out of encrypted file system |
1,446,884,727,000 |
I have an encrypted hard drive on my Lan Server. It was encrypted using luks/dm-crypt. The server has a NFS v4 running to share files in the Lan. It works, except for the encrypted USB hard drive. If the client mounts the shares into his file system, he finds an empty folder where the decrypted files should be.
This is the setup:
How the server mounts the luks partition:
sudo cryptsetup luksOpen /dev/sdb1 data1
sudo mount /dev/mapper/data1 /exports/user1/data1
Decrypting and mounting the drive on the server works fine. If I go to /exports/user1/data1 I get the decrypted files.
The NFS exports:
/exports 192.168.178.20(rw,sync,fsid=0,no_subtree_check,root_squash) 192.168.178.21(rw,sync,fsid=0,no_subtree_check,root_squash)
/exports/user1 192.168.178.20(rw,sync,no_subtree_check,root_squash) 192.168.178.21(rw,sync,no_subtree_check,root_squash)
So the decrypted USB drive is mounted right into the NFS exports at /exports/user1/data1
And this is how the client mounts the shared folder:
sudo mount.nfs4 192.168.178.10:/ /fs_data -o soft,intr,rsize=32768,wsize=32768
Now, if the client mounts the server exports into his file system, he finds the 'data1' folder empty.
Is there anything I'm missing?
Update:
Thanks to Gilles great answer I got it working. I tried to avoid crossmnt and nohide to not run into eventual inode problems. This is what I use now:
/etc/exports
/exports/user1 192.168.178.20(rw,sync,fsid=0,crossmnt,no_subtree_check)
/exports/user1/data1 192.168.178.20(rw,sync,no_subtree_check)
client command to mount data1:
sudo mount.nfs4 192.168.178.10:/data1 /fs_data -o soft,intr,rsize=32768,wsize=32768
|
With the Linux kernel NFS server, if you export a directory tree, this does not include any filesystems mounted on that tree. See the description of the nohide option in the exports(5) man page.
You need to export the mounted filesystem explicitly, i.e. you need a separate line in exports for /exports/user1/data1. Furthermore you'll need to (re)start the NFS server after mounting /exports/user1/data1.
On the client side, you need to mount /fs_data/data1 separately. As discussed in the exports man page, you can avoid this by including the nohide option on /exports/users1/data1, or the crossmnt option on /exports/users1, but this can cause trouble because the client will see files with the same inode number on what appears to be the same filesystem. This can, for example, lead a file copy or archiving program to omit files because it thinks it's already backed them up (if the program has seen /fs_data/foo with inode 42, it'll think that the unrelated file /fs_data/data1/bar with inode 42 on what appears to be the same filesystem — but actually isn't — is the same file).
| NFS v4 export encrypted partition. Client mounts empty dir |
1,446,884,727,000 |
I have certain folders in my Linux partition which I need to make sure no one can access unless the log in with my login password (or root one).
I know that during installation I can encrypt with LUKS and I can encrypt certain folders with encfs / Truecrypt.
However the encryption password is independent from current user and root password and unless I store it (which I guess it'd make it useless), I'd have to insert password manually each time.
Also, if any program on startup is accessing certain files (e.g. Timeshift for boot backups) will fail.
Therefore I'm looking for a solution which allows me to encrypt the whole system (or only certain folders) post OS-installation which is dependent on user or root password and which
doesn't impact any application which has the permission to access those folders (at any time after login)
doesn't make impossible or nearly impossible to recover the system should it fail (I read that even GRUB has issue if the partition is encrypted)
|
You will need to use a different user than the account that you are setting up encryption for (this is primarily the 'root' user but could be any user who has access to 'sudo'). Do the following:
Install these packages: "apt-get install ecryptfs-utils cryptsetup"
Run the following using either root or a user with root privileges: * "ecryptfs-migrate-home -u PutTheUserNameWhoYouAreEncryptingTheirHomeDirHere"
Lastly encrypt the swap by running: "ecryptfs-setup-swap"
Good luck :)
| How to encrypt Linux (Debian 8) post-installation and what are the consequences? |
1,446,884,727,000 |
After validating of my public XMPP service on xmpp.net, I've got the error:
Warning: Server offers no forward-secret ciphers. Grade capped to A-.
Is there an easy way to enable these ciphers? As title states, I have Debian Stable and ejabberd installed from its repository.
ADDITION
I've checked all the servers listed in https://xmpp.net/directory.php which have ejabberd installed with its build date 2011/12/24. This is Debian Wheezy's ejabberd obviously. The top score of any of these servers is A-/A-, so I believe it is really difficult to enable PFS for this software.
|
There is no known possibility to restrict Debian 7 Wheezy's ejabberd 2.1.10 to use certain ciphers. The only solution is to upgrade to a more recent ejabberd version, Debian 8 Jessie's ejabberd 14.07 for example.
| Debian Wheezy, ejabberd and forward secrecy |
1,446,884,727,000 |
I have some encrypted volumes that I use with my Xubuntu machine. One volume is a container file that is mapped to /dev/loop0 and encrypted using plain dm-crypt; another volume is a USB hard drive encrypted using dm-crypt/LUKS.
What I'd like to know is what would happen if I accidentally shut down the computer without unmounting and unmapping these volumes? Is it any more risky than if the volumes weren't encrypted?
Similarly, what would happen if I had to hard-reboot the machine without unmapping the volumes, because the system froze for example?
|
The short answer is that encrypted volumes are not really more at risk.
The encrypted volumes have a single point of failure in the information at the beginning of the volumes that maps the password (or possibly several passwords for systems like LUKS) to the encryption key for the data. (That is why it is a good idea to encrypt a partition and not a whole disc, so that accidental partitioning doesn't overwrite this data).
This data does, AFAIK, not have to be updated unless one of the passwords changes, so the chances of it getting corrupted because a shutdown while it is half-written are low.
The rest of the disc is normally accessible with the encryption key retrieved from the above information block. Normal filesystem recovery is possible given that key.
You can make a backup of the LUKS header. But you have to realise that when you do and change one of the passwords later on (e.g. because it was compromised), that the backup "uses" the old passwords.
| Are encrypted volumes more vulnerable to power loss? |
1,446,884,727,000 |
My Raspberry Pi is set up as a PHP MySQL (Percona) server and I think that I have managed to make it quite resilient against online attacks but it is still very vulnerable against someone just taking out the SD card and reading all my data. I guess I could encrypt the important stuff in MySql but the encryption keys would still be in plain text PHP files and I guess that I could encrypt the PHP and/or MySQL folders but that would all just get complex and there would still be cache and logs etc. to worry about. Someone could probably also see the hashed password and use a rainbow table to crack them. Correct me if I am wrong but as I see it the simplest to manage and most secure solution would be to just encrypt the entire drive (excluding boot and kernel obviously).
Now the only problem is that I cannot really figure out how to do that. The best link I could find was this one https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_Entire_System but as far as I can determine this only explains what you should do for a fresh installation but unfortunately I have already installed a lot of packages and have made a lot of configurations which I would like to keep.
Could someone please explain to me (or provide a link I guess) in simple terms what exactly I should do to fully encrypt my existing Arch Linux installation.
PS. I can understand that for full encryption a key needs to be entered at boot but I could not determine if that requires a physical terminal (screen + keyboard) on the device (which I don't really have but I can get if needed) or if I will be able to do it over the network?
EDIT:
I have found a sort of tutorial for setting up this on Arch here https://gist.github.com/pezz/5310082. My only problem is that I cannot get the remote unlock to work. I have tried copying my public key into /etc/dropbear/root_key but when I try to ssh in with my private key I am still asked for the password of root and neither the actual password of root nor the password used to unlock the drive gets accepted. As mentioned by the tutorials for Debian in one of the answers here I tried copying the private key generated by Dropbear which in my case I think is /etc/dropbear/dropbear_rsa_host_key to my client but then when I try to ssh in with this key I am asked for a pass phrase for the key, any idea?
|
There are three separate issues involved in what you are trying to accomplish.
Encrypting an existing system. The correct way to do this would be to back up your exisiting install to another drive and start with a fresh install and rsync your relevant system files across once you have set up your encrypted Pi. This way you would be sure that you would not lose any data and would have a genuinely encrypted Pi (using the method described on the Arch Wiki LUKS page).
The problem with this approach is that the Archlinux ARM images are distributed as .img files and are intended to be dd'ed onto an SD Card, so—using the standard installation method—there is no opportunity to implement a more complex install, such as LUKS or LVM. One of the Archlinux ARM developers addressed this in a forum post and recommended using this script. This blog post has some specifics.
The third issue you will face is unlocking the encrypted device remotely. The standard method for doing this is using busybox and dropbear, as described in this U&L answer. This blog post has the details for a Debian Pi, but it should work for the Arch version.
| Arch Linux Encrypt entire drive |
1,446,884,727,000 |
I'd like to use dropbear as an alternative, minimal ssh-server and -client. dropbear allows the use of private-public-keys for ssh-access, although the keys are not identical to the ones used by openssh and have to be converted using the dropbearconvert-command (which is easy to do).
The issue I'm having is that dropbear doesn't natively support encrypted private keys. But leaving unencrypted ssh-keys on my laptop is something I'd like to avoid out of principle.
Therefore my question: does anyone have any good ideas on how to circumvent that issue and have a method (script?) that:
decrypts the keys I use for dropbear (e.g. using gnupg) and loads them into memory,
passes them to the dbclient-binary (the dropbear-client-application), and
starts the ssh-connection
In addition I'd like to know if an alternative to the ssh-config option (especially the ones for Host) exists for dropbear (and therefore if it is possible to create a host-specific config file for dropbear where I can specify e.g. the IP-address, the port and other details).
|
It appears that dbclient is entirely willing to read the private key from a named pipe or FIFO.
So with bash's process substitution, you can write:
dbclient -i <(cat .ssh/id_dropbear) user@server
So if you have a GPG encrypted .ssh/id_dropbear.gpg, you can write it as:
dbclient -i <(gpg --decrypt .ssh/id_dropbear.gpg) user@server
And after entering your decryption password, dbclient logs in using your GPG encrypted private key. So that part works fine.
The main issue here is that if you already stored .ssh/id_dropbear unencrypted before that, it could be recovered forensically. To encrypt a key on the fly from dropbearconvert, you can apply the same principle:
$ dropbearconvert openssh dropbear \
.ssh/id_openssh >(gpg --symmetric --output .ssh/id_dropbear.gpg)
Key is a ssh-rsa key
Wrote key to '/dev/fd/63'
But it does not seem to be too useful in practice, since dropbearconvert also offers only very limited support for OpenSSH's encrypted private keys. For this example I had to specially create an OpenSSH key that dropbearconvert understands...
Unfortunately, this trick does not seem to work at all for the dropbearkey command, which for some reason insists on writing to a temporary file and renaming it, circumventing the pipe entirely.
Thus it appears you have no choice but to generate the private key in tmpfs first (like in /dev/shm or from a live cd), and encrypt it from there.
| encrypt private keys for dropbear ssh-access |
1,446,884,727,000 |
I believe that the exact procedure below worked for me two weeks ago, but now it doesn't. I start with an RSA private key rsa.pem and generate my own self-signed certificate:
openssl req -new -x509 -key rsa.pem -out rsa.cer
then I try to create a p12 file:
openssl pkcs12 -export -out rsa.p12 -inkey rsa.pem -in rsa.cer
but I only get the following message:
Usage: pkcs12 [options]
where options are
-export output PKCS12 file
-chain add certificate chain
-inkey file private key if not infile
-certfile f add all certs in f
-CApath arg - PEM format directory of CA's
-CAfile arg - PEM format file of CA's
-name "name" use name as friendly name
-caname "nm" use nm as CA friendly name (can be used more than once).
-in infile input filename
-out outfile output filename
-noout don't output anything, just verify.
-nomacver don't verify MAC.
-nocerts don't output certificates.
-clcerts only output client certificates.
-cacerts only output CA certificates.
-nokeys don't output private keys.
-info give info about PKCS#12 structure.
-des encrypt private keys with DES
-des3 encrypt private keys with triple DES (default)
-seed encrypt private keys with seed
-aes128, -aes192, -aes256
encrypt PEM output with cbc aes
-camellia128, -camellia192, -camellia256
encrypt PEM output with cbc camellia
-nodes don't encrypt private keys
-noiter don't use encryption iteration
-nomaciter don't use MAC iteration
-maciter use MAC iteration
-nomac don't generate MAC
-twopass separate MAC, encryption passwords
-descert encrypt PKCS#12 certificates with triple DES (default RC2-40)
-certpbe alg specify certificate PBE algorithm (default RC2-40)
-keypbe alg specify private key PBE algorithm (default 3DES)
-macalg alg digest algorithm used in MAC (default SHA1)
-keyex set MS key exchange type
-keysig set MS key signature type
-password p set import/export password source
-passin p input file pass phrase source
-passout p output file pass phrase source
-engine e use engine e, possibly a hardware device.
-rand file:file:...
load the file (or the files in the directory) into
the random number generator
-CSP name Microsoft CSP name
-LMK Add local machine keyset attribute to private key
I'm just following previous posts:
https://stackoverflow.com/questions/38841563/create-rsacryptoserviceprovider-object-using-rsa-private-key-file-in-c-sharp
https://stackoverflow.com/questions/10994116/openssl-convert-pem-containing-only-rsa-private-key-to-pkcs12
|
Turns out to be a character encoding issue with the dashes, which is confused from copy & pasting. I just re-typed the command and it worked.
| How to produce p12 file with RSA private key and self-signed certificate |
1,446,884,727,000 |
I am trying to copy a directory from one system to another with rsync; but it erred. Can you please advise me on what to check?
Command:
[M root@aMachine ~]# rsync -e "ssh -c blowfish" -v -a /home/aDir/ [email protected]:/home/aDir
Output:
ssh_dispatch_run_fatal: no matching cipher found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
I tried couple attempts in /etc/ssh_config, but to no avail. This is what I have in my /etc/ssh_config now:
# Host *
# ...
# ...
# Port 22
# Protocol 2,1
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
IdentityFile /root/.ssh/identity
IdentityFile /root/.ssh/id_rsa
IdentityFile /root/.ssh/id_dsa
IdentityFile /etc/static_keys/CURRENT
|
You are trying to force the use of the blowfish cipher ("ssh -c blowfish"). According to your configuration, this cipher is not available (the SSH configuration, by default, shows the default configuration settings as comments).
Unless you have any compelling reason to do so (none was mentioned in your post), do not force the use of a particular cipher.
Notice also that you usually do not have to fiddle with /etc/ssh/ssh_config. As a user, it's easier to modify $HOME/.ssh/config. You are working on this system as a non-root user, aren't you?
| "no matching cipher found" error in `rsync` |
1,446,884,727,000 |
My home server runs OpenBSD 5.3 with Samba serving files to several Windows machines. I wrote a script to backup video files by encrypting each file with openssl enc -aes-256-cbc and uploading it to Amazon S3. To test one possible restore scenario, I tried running the script on a file, downloading the file to one of the Windows machines, and decrypting it using several programs advertised as decrypting AES-encrypted files, but they weren't able to decrypt it. Can a file encrypted by OpenSSL be decrypted only by OpenSSL? Can a file encrypted by OpenSSL on OpenBSD be decrypted only by OpenSSL on OpenBSD?
For the record, I had no problem downloading the file to my server and decrypting it using OpenSSL. However, I'm interested in knowing if my videos on S3 (quickly archived to Glacier) can remain accessible regardless of my choice of server setup.
|
AES-CBC-256 fully specifies an encryption algorithm and a decryption algorithm. Given a plaintext, a key and an IV, two implementations of AES-256-CBC encryption will produce the same ciphertext. Given a ciphertext, a key and an IV, two implementations of AES-256-CBC will produce the same plaintext.
The IV is a random string that is generated when you encrypt a messsage. If you encrypt the same data twice, you'll get different ciphertexts because the IV will be different. This is in part so that someone who can only see two ciphertexts with the same length cannot detect whether the ciphertexts are equal. Most tools prepend the IV to the ciphertext, so that all the data needed for decryption is in one place (except the key, of course).
The OpenSSL command line tool generates a file containing a 16-byte header, the IV, and the ciphertext. This format is specific to OpenSSL but does not depend on the platform.
OpenSSL's command line is intended more as a demo of the possibilities of the library than a production-grade command line tool. I don't recommend using it, it's too easy to make a mistake and either end up with non-recoverable data or insecure data. Also OpenSSL won't help you with key management.
Instead, use a tool that is intended to encrypt file. GPG is designed for this purpose. Generate a key pair, and then encrypt files with gpg -e [email protected] /path/to/file.
| Decrypting a file encrypted on a different system |
1,446,884,727,000 |
We have an automated sync-routine that uses useradd to create new users on a Ubuntu 10.04 machine. The application launching the routine provided both username and CRYPT-encrypted password. However, since we changed how passwords are handled in order to include LDAP support, passwords now don't have to be CRYPT but can also be MD5 or SHA-1. In fact, SHA-1 is the new default. This however now causes problems.
I have read up on how /etc/shadow is handled and there doesn't seem to be an id for SHA-1, only for SHA-256/SHA-512($5$ and $6$ respectively). The only thing I found was to change the whole thing from CRYPT to SHA-1. We could do that, but we wanted the whole transition to be as non-disruptive as possible.
Is there a way to use both CRYPT and SHA-1 passwords together?
NOTES
- The main application is a CMS on an entirely different server. The linux server in question is a local machine(slave) at the client's location in order to provide local services.
- We are aware that we could switch the entire system out to use LDAP-only, but, as outlined earlier, we don't want to change everything at once.
|
Why not authenticate those users for which you only have an unsalted SHA-1 hash of their password by another means than /etc/shadow.
Using PAM, you can have as many authentication modules as you want and stack them as you want. You can keep pam_unix.so for some users and use pam_ldap.so for the rest.
| Can linux use a mix of SHA-1 and CRYPT passwords? |
1,446,884,727,000 |
I just tried to set up Debian in a VM (just testing, before installing it on a real system).
I have set up 4 drives in total. 2 drives that simulate pen drives, on which I want to install the boot loader and boot file system later, and another 2 drives. Every drive is configured as encrypted RAID1 (md0_crypt and md1_crypt). However, I can't put the boot filesystem on my md0_crypt, because I get the warning that one cannot store the /boot FS on an encrypted partition, because it needs to load the kernel and initrd.
So, do I stand correctly that I cannot encrypt my /boot FS? Is the boot FS only for the boot loader (grub) or is there anything else? I would like to have the scenario that if I unplug my pen drive that the system can't be started anymore, since the /boot FS is installed on the pen drive.
|
As the message describes you can't put /boot in an encryption container.
For unlocking the encryption container you need to access some utilities. If these utilities are inside the encryption container you are in a deadlock situation.
As a work-around use a unencrypted small 3rd raid container holding only the /boot file system.
From the security perspective this isn't a big loss. The /boot should only contain technical data.
There is a small caveat: If you use a password for GRUB, it should be different from the pass-phrase for the encryption container.
| Encrypt boot file system |
1,446,884,727,000 |
Yesterday I was trying using the Debian install in rescue mode in order to fix my Grub (The menu-item for Debian was suddenly gone).
Now I wasn't able to fix it and didn't have a lot of time, so I thought I'd just reinstall Debian (I know, windows style :P). Problem was that I had installed Debian using full disk encryption, thus within a LVM partition. For some reason the installer didn't recognize the volume groups, though I could mount them in rescue mode. I tried to set "use as lvm" and then select option "use current layout", but no volume groups were present anymore. Going back to rescue mode, executing a shell, I couldn't mount them anymore, as if they were gone.
So somewhere along the way the metadata for the volume groups must have been overwritten. I did some googling, but hardly found anything on the specific subject of overwrittten metadata. I've tried running testdisk, but it seems that's only for recovering partitions, not volume groups.
Last I could find was the output of pvck:
root@ubuntu:/home/ubuntu# pvck -d -v /dev/sda5
Scanning /dev/sda5
Found label on /dev/sda5, sector 1, type=LVM2 001
Found text metadata area: offset=4096, size=192512
Found LVM2 metadata record at offset=194560, size=2048, offset2=0 size2=0
Found LVM2 metadata record at offset=128512, size=66048, offset2=0 size2=0
Found LVM2 metadata record at offset=116224, size=12288, offset2=0 size2=0
Found LVM2 metadata record at offset=69120, size=47104, offset2=0 size2=0
Found LVM2 metadata record at offset=68096, size=1024, offset2=0 size2=0
Found LVM2 metadata record at offset=65024, size=3072, offset2=0 size2=0
Found LVM2 metadata record at offset=53248, size=11776, offset2=0 size2=0
Found LVM2 metadata record at offset=52736, size=512, offset2=0 size2=0
Found LVM2 metadata record at offset=51712, size=1024, offset2=0 size2=0
Now that does look like it found something right? But unfortunately I don't know enough about LVM's, so I have no idea how to use this information. Anyone who is able to guide me further?
Extra information:
output of pvscan:
root@ubuntu:/home/ubuntu# pvscan
PV /dev/sda5 lvm2 [465.52 GiB]
Total: 1 [465.52 GiB] / in use: 0 [0 ] / in no VG: 1 [465.52 GiB]
I am testing on live Ubuntu 10.04 LTS 32-bit live-cd and I was trying to reinstall Debian Squeeze 64-bit. I am using a Acer Aspire laptop with intel i7 quad-core processor, 2x 1TB internal hard drives, ati Radeon HD 5600 Series videocard. (which is probably more information than needed :P).
|
Gave up and formatted the drive containing the lvm as I was really in need of more space.
| Recovering overwritten LVM metadata |
1,446,884,727,000 |
I was trying to encrypt all the HDD during the installation process of Debian 8 Jessie using full disk encryption + LVM, and I did it, but, there are a little "problem".
Before the system asks me the password to unlock the disk, it display a message:
Loading, please wait...
[5.004102] sd 2:0:0:0: [sda] Assuming drive cache: write through
Volume group "lvm_group" not found
Skipping volume group lvm_group
Unable to find LVM volume lvm_group/root
Volume group "lvm_group" not found
Skipping volume group lvm_group
Unable to find LVM volume lvm_group/swap
Please unlock disk sda5_crypt:
But when I introduce the password and press Enter, the system boots successfully without any problem. I can't understand why.
I found some people with the similar issues in other forums and articles/manuals, but the ones I found just can't boot after the message "Unable to find LVM volume", but I can boot the system after introducing the password.
My fstab:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/lvm_group-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=4f7e12ab-84d3-4715-bab4-62cf5033ca8a /boot ext4 defaults 0 2
/dev/mapper/lvm_group-home /home ext4 defaults 0 2
/dev/mapper/lvm_group-swap none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
My crypttab:
sda5_crypt UUID=21feadfc-72e7-4a2c-b5f2-0c9ca3137b03 none luks
My /proc/cmdline:
BOOT_IMAGE=/vmlinuz-3.16.0-4-amd64 root=/dev/mapper/lvm_group-root ro quiet
So how can I fix it and avoid these messages? I feel like I've tried everything.
|
It's not an error, so you shouldn't try to make it go away.
The scripts in your initramfs are opportunistically checking to see if they can activate the LVM VG that contains your root device before they bother asking for a passphrase to decrypt any encrypted devices. In the case that your root device is not encrypted, this will work, and the system will proceed to boot without delay. Otherwise, you get an opportunity to enter a passphrase to decrypt any possible encrypted devices, and then it tries again to access the VG. See:
/usr/share/initramfs-tools/scripts/local-top/lvm2
/usr/share/initramfs-tools/scripts/local-top/cryptroot
especially the function activate_vg() in each of those scripts.
| Debian error message: "Unable to find LVM volume", but then boots successfully |
1,446,884,727,000 |
So far I have a Debian NAS with a samba share accessible from a Windows client by user credentials. Within that share I have a folder of images encrypted by ecryptfs. A friend of mine have agreed to "host" a synced copy of my encrypted images on his NAS, but at the same time I want a synced copy/access of decrypted images on my Windows machine.
One idea is if some encryption tool on NAS is able to always maintain two folders of the same data; one encrypted, one decrypted? and then share them accordingly with btsync or similar.
disadvantage of this would be double the space used.
Better specified suggestion of above or other solutions to my problem are greatly appreciated!
|
If you were using a tool like eCryptfs that decrypts file "on-the-fly", you could mount and share the decrypted data in a "Visible" folder, and also separately share the encrypted data in the ".Private" folder.
The "Visible" folder's decrypted data is only visible while mounted, and it doesn't take up any extra disk space since it's not a hard on-disk decrypted copy (that would be extremely insecure). Unmounting it stops the decryption and leaves only the encrypted ".Private" folder.
See the eCryptfs documentation here http://ecryptfs.org/documentation.html
Especially these entries:
ecryptfs-setup-private - setup an eCryptfs private directory.
ecryptfs-mount-private - interactive eCryptfs private mount wrapper script.
EncFS works similarly, isn't supposed to require root access, but isn't usually installed by default on most distro's I've seen (like Mint, Ubuntu...)
| How to encrypt data in a folder in a samba share, and share it both encrypted and decrypted? |
1,446,884,727,000 |
I am wondering if it is possible to :
Store a mailbox in a way that the system administrator (ie: root) cannot see it
User(s) with the valid credentials would be able to see it AND be able to search quickly in it, preferably via http access
I know that I can:
Encrypt on the partition level, but it won't disallow the system administrator from seeing files in it.
Encrypt emails with the GPG system, but I don't if and how I could apply it to an entire mailbox (ie: past and future emails in this mailbox).
Give access to a mailbox via an open source webmail like roundcube, but I don't know if and how he would be able to access an encrypted mailbox
Do you know if this is possible?
|
This is impossible: root can always access all data. Even if you encrypt it, as soon as you decrypt it for access, root can snoop on the data, and snoop on your credentials as well. You cannot protect anything from the local root.
You can store files on a machine whose administrator you don't rust, but you need to encrypt and sign them. This means that you'll only be able to search them on a machine that you trust. You can store the email and search indices on the untrusted machine, but the search must happen on a trusted machine. There is ongoing research on forms of encryption that could allow searching, but this is difficult (searchable and encrypted are fundamentally contradictory) — don't expect usable software anytime soon, if ever.
| Is there a good way to encrypt and store a mailbox while still being able to quickly access and search it? |
1,446,884,727,000 |
I'm trying to use encryption inside a virtual machine. The problem is that the AES-NI doesn't seem to be passed to the guest virtual machine.
I have Vt-x enabled.
This is my host cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
stepping : 7
cpu MHz : 1600.000
cache size : 8192 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
bogomips : 6801.03
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
This is my guest cpuinfo:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
stepping : 7
cpu MHz : 3399.615
cache size : 6144 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl pni ssse3 lahf_lm
bogomips : 6799.23
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Am I missing some configuration option? Or is this a problem of Virtualbox?
|
That's the normal state in Virtualbox, see here.
| AES-NI not passed to guest in Virtualbox |
1,446,884,727,000 |
I am considering building a small home server. I'd like to encrypt some folders on this server, therefore using the instruction set aes-ni which is supported by newer (mostly Intel) chips would be advantageous.
Is there a way to use aes-ni with Debian, or is there at least an alternative kernel that supports it?
[edit] Or is it already supported by default: http://kernel.alioth.debian.org/config/2.6.38-2/config_amd64_none_amd64?
|
It does look like it is configured in the config you listed (as CONFIG_CRYPTO_AES_NI_INTEL=m, which means configured as a module), but regardless, it is easy to build your own custom Debian kernels. See the Debian Kernel Handbook. You want 1.10, the version online is 1.09 which is out of date. The only downside of compiling a custom kernel is that you need to rebuild whenever there are security updates (and keep track of the security updates). The stock kernel updates arrive automatically via the package management system.
Manoj Srivastava's kernel-package is also used for this, but the Debian Kernel team use the procedures outlined above in the handbook to build the stock kernels, for example, so I think it is a better way to go.
| Use aes-ni in Debian |
1,446,884,727,000 |
Concise question: Is it possible to somehow bind partition encryption to hardware so it is impossible(very hard) to copy system to another PC and run there?
Full story: We have a small embedded PC with Linux running inside a device, we develop. As the device turns on, embedded PC just runs, showing data to users until power-off.
Software on this PC is our commercial competitive advantage so we would like to prevent access to it as much as possible (see P.S.).
So the idea is to encrypt the system flash or at least a part of it. But then it is possible just to copy the entire flash. Then, the next idea is to bind the encryption to hardware. But how?
P.S. I know that everything is a subject for reverse engineering, but it is not the reason to leave reverse engineering of your product flat and unchallenging.
P.P.S I'm not paranoid about copying. Unfortunately, we know competitors who will try to steal the technology by names =)
|
You can bind encrypted data to a specific device using a Trusted Platform Module (TPM). These have become quite common in x86 laptops over the last few years, and can be installed in many servers too.
Using a TPM, you can generate an encryption key which only exists in the module, and encrypt data using that; if you generate a key which can't be backed up, then you can be sure that the data can only be encrypted with the corresponding TPM. Copying the raw storage device is useless then. On Linux you could use TrouSerS to manage this.
On ARM platforms you could do something similar with a key stored using TrustZone, but I don't know the details.
| Prevent encrypted partition from running on other PC |
1,446,884,727,000 |
How can I encrypt a large file with a public key so that no one other than who has the private key be able to decrypt it? I don't want to use GPG!
|
This could be used to encrpyt a file mypic.png, given you already have a private/public keypair in ccbild-key.pem/ccbild-crt.pem. (You can find a guide to creating a keypair in this answer.)
# encrypt
openssl smime -encrypt -aes-256-cbc -binary -in mypic.png -outform DER -out mypic.png.der ccbild-crt.pem
# decrypt
openssl smime -decrypt -binary -in mypic.png.der -inform DER -out mypic.png -inkey ccbild-key.pem
Note that the settings may not reflect best practice in selection of crypto standard (in particular if you read this in the future), also it might not be a good choice performance-wise. (We only use it for sub-1M files in our application.)
| How can I encrypt a large file with OpenSSL using RSA keys? |
1,446,884,727,000 |
I've read in various places, such as in this question that using an ssh key pair without a passphrase allows attackers to steal your private key if they gain access to your account. I assumed that by "steal" it meant they could fairly easily do a brute-force attack to try every possible private key until they found one that matched the public key stored in your account. But the accepted answer on the question above assumes that the private keys are essentially stored in plain text somewhere. This is contrary to what I've always understood to be the case: that since (normally) you wouldn't store your private key on the server--only your public key--the main security risk posed by not using a passphrase is that someone could steal the private key off of your local machine and then use it without needing to also know the passphrase.
Which view is correct? Are private keys somehow easily lifted from a server on which you only placed your public key?
|
That question is worried about private keys stored on the server unencrypted. It's a scenario like:
workstation 1 ---> gateway -> final server
⋮ |
workstation n ------/
and the OP is worried about private keys on "gateway", which is a shared machine with multiple users.
It is not possible to steal the private key by compromising the server, only the machine the key is actually stored on. If you use ssh agent forwarding, then its possible to use the key without stealing it (to log into another machine, for example), if you do not have ssh-agent prompt first.
But you should still encrypt your private keys, in case your workstation is compromised. Or, especially in the case of a laptop, lost or stolen.
| Is it *really* possible to directly steal a private key if it uses no passphrase? |
1,446,884,727,000 |
On my Debian Linux system during the install I decided to use disk encryption (the one offered during a regulard Debian install). When the system boots up I need to enter a password and then the "real" boot begins.
Could someone explain how this encryption is performed? Does it happen before or after the filesystem's laid out? Can I use any filesystem available for Linux with the disk encryption?
The /etc/mtab/ is more complicated than what I was used with Linux and I take it it's related to disk encryption but I'm really not sure. Here's (what I think is) the relevant bits from my /etc/mtab:
/dev/sda1 /boot ext2 rw,relatime,errors=continue 0
/dev/mapper/archon-root / ext4 rw,noatime,errors=remount-ro,user_xattr,commit=300,barrier=1,data=ordered 0 0
rootfs / rootfs rw 0 0
I don't really understand why /boot is ext2 and why / is ext-4 and using a /dev/mapper.
Could /boot be itself using ext4?
Could / be using, say, ZFS and yet still offer encryption?
|
/boot is not encrypted (the BIOS would have no way to decrypt it...). It could be ext4, but there really isn't any need for it to be. It usually doesn't get written to. The BIOS reads GRUB from the MBR, then GRUB reads the rest of itself, the kernel, and the initramfs from /boot. The initramfs prompts you for the passphrase. (Assumably, its using cryptsetup and LUKS headers.).
The encryption is performed at a layer below the filesystem. You're using something called dm-crypt (that's the low-level in-kernel backend that cryptsetup uses), where "dm" means "Device Mapper". You appear to also be using LVM, which is also implemented by the kernel Device Mapper layer. Basically, you have a storage stack that looks something like this:
1. /dev/sda2 (guessing it's 2, could be any partition other than 1)
2. /dev/mapper/sda2_crypt (dm-crypt layer; used as a PV for VG archon)
3. LVM (volume group archon)
4. /dev/mapper/archon-root (logical volume in group archon)
5. ext4
You can find all this out with the dmsetup command. E.g., dmsetup ls will tell you the Device Mapper devices in list. dmsetup info will give some details, and dmsetup table will give technical details of the translation the mapping layer is doing.
The way it works is that the dm-crypt layer (#2, above) "maps" the data by performing crypto. So anything written to /dev/mapper/sda2_crypt is encrypted before being passed to /dev/sda2 (the actual hard disk). Anything coming from /dev/sda2 is decrypted before being passed out of /dev/mapper/sda2_crypt.
So any upper layers use that encryption, transparently. The upper layer you have using it first is LVM. You're using LVM to carve up the disk into multiple logical volumes. You've got (at least) one, called root, used for the root filesystem. It's a plain block device, so you can use it just like any other—you can put any filesystem you'd like there, or even raw data. The data gets passed down, so it will be encrypted.
Things to learn about (check manpages, etc.):
/etc/crypttab
LVM (some important commands: lvs, pvs, lvcreate, lvextend)
cryptsetup
| Encrypted disk filesystem compatibilities |
1,446,884,727,000 |
I do not hold a deep understanding of computer science concepts but would like to learn more about how the utility encfs works. I have a few question regarding the concept of filesystem in regards to encfs. It is said that encfs is a cryptographic filesystem wiki link.
1)To encrypt the files encfs is moving around blocks of the files to be encrypted, so am I correct to see this 'scrambled' version of the files as a new perspective which justifies the term of a new filesystem?
2)In the man pages of encfs in the section CEVEATS link to man of encfs online, it says that encfs is not a true file system. How should I understand this? Is that because some necessary features common to all file systems is missing in encfs' file system? Or is because of some other more substantial reason?
3)The man pages say that it creates a virtual encrypted file system. There are two questions here; what is it that makes it virtual is it that it is a file system within a file system? and the encrypted is that there is not a straight forward way to map the file blocks into a format to be read by other programs?
4)How does the command fusermount relate to encfs?
|
I think that behind your description, there is a misconception. The unencrypted data is not stored on the disk at any point. When you write to a file in the encfs filesystem, the write instruction goes to the encfs process; the encfs process encrypts the data (in memory) and writes the ciphertext to a file. The file names, as well as the file contents, are encrypted. Reading a file undergoes the opposite process: encfs reads the encrypted data from the disk file, decrypts it in memory and passes the plaintext to the requesting application.
When you run the encfs command, it does not decrypt any data. It only uses the password that you supply to unlock the filesystem's secret key. (This is actually a decryption operation, cryptographically speaking, but a different type from what happens with the file data. I will not go into more details here.)
1) Encfs is not exactly “moving blocks around”; it is decoding blocks when it reads them. Encfs is a filesystem because it behaves like one: you can store files on it, when it's mounted.
2) Encfs is not a “true” filesystem because it doesn't work independently. Encfs only provides an encryption layer; it uses an underlying filesystem to actually store data and metadata (metadata is auxiliary information about files such as permissions and modification times).
3) Virtual filesystem is another way to say that encfs itself doesn't store any data, it needs an underlying filesystem (see (2) above) for that. Encrypted means just that: encfs stores the data that you put in it in an encrypted form, which cannot be decrypted without the key. Another program could read the data stored by encfs if and only if that other program had access to the key (which requires the password that the key is protected with).
4) The fusermount command sets up a FUSE mount point. You would not normally call it directly, because a FUSE filesystem is implemented by a user-mode process which you have to start anyway, and that process (e.g. encfs) will take care of setting up the mount point. Unmounting a FUSE filesystem, on the other hand, is a generic operation, you can always do it by calling fusermount -u.
| How to understand the filesystem concepts used by encfs? |
1,446,884,727,000 |
I currently have an unencrypted external hard drive that I use as a backup for my encrypted (with LUKS) main machine. To update my backup, I simply log in to the main machine and rsync to my external hard drive. Clearly, having an unencrypted backup for material that was worth encrypting in the first place is a bad idea. However, due to time constraints, I am unable to regularly update my backup without the help of something like rsync. It follows that any encryption method that I use on the external drive must be compatible with rsync. However, I have ran in to the following issues:
Userspace stackable encryption methods like EncFS or eCryptfs appear to both take up a lot of space and not play nice with rsync. The hidden files reponsible for the encryption seem to change frequently enough that rsync ends up having to copy so many files that it's barely worth even using rsync.
luksipc would be an option, but it's latest documentation tells me to instead use the the cryptsetup-reencrypt tool from dm-crypt. Sadly, whenever I look up the relevant documentation on the arch wiki for cryptsetup-reencrypt I can neither tell what to do, nor if it'll work with rsync. The cryptsetup-reencrypt tool also seems to be new enough that it's hard to find doccumentation on it that someone at my level can read.
Plain LUKS, or anything similar isn't an option, because the earlier mentioned time constraints prevent me from being able to wipe the drive and make the backup again from scratch.
Duplicity could be an option, but it doesn't seem able to encrypt any unencrypted files that are on the external hard drive (i.e. where it's copying to).
Overall, it looks like #2 might be my best option for the goal of encrypting my external drive and keeping that drive up to date with rsync, but I don't really know where to begin and I'm not very open to the possibility that I might have to wipe the drive before encrypting it. Am I missing anything useful?
|
Nowadays cryptsetup itself supports non-destructively transforming an unencrypted partition into a encrypted LUKS device with the reencrypt subcommand.
Assuming that your external drive is accessible via /dev/sdX and the current filesystem is located on /dev/sdXY you need first shrink the filesystem to make room for the LUKS header and some scratch space for the encryption operation (32 MiB works). The exact command depends on you filesystem, e.g. for ext4:
e2fsck -f /dev/sdXY
resize2fs /dev/sdXY NEWSIZE
(Note that XFS doesn't support shrinking, thus you would need to fstransform it first ...)
Trigger the encryption:
cryptsetup reencrypt --encrypt /dev/sdXY --reduce-device-size 32M
Enlarge the filesystem again:
cryptsetup open /dev/sdXY backup
resize2fs /dev/mapper/backup
cryptsetup close backup
(without a size argument resize2fs uses all available space)
Since you don't change the content of you existing filesystem you can continue using rsync. Instead of something like
mount /dev/sdXY /mnt/backup
rsync -a /home /mnt/backup
umount /mnt/backup
you now have to do something like:
cryptsetup open /dev/sdXY backup
mount /dev/mapper/backup /mnt/backup
rsync -a /home /mnt/backup
umount /mnt/backup
Since you mention your time constraints: cryptsetup reencrypt isn't necessarily as fast as a cryptsetup luksFormat followed by a fresh rsync.
An alternative to the above is to switch to Restic for your backup needs. Restic encrypts all backups, supports incremental backups and is very fast.
If your external drive is large enough you can start with Restic by initializing a Restic repository in a new subdirectory. After the first Restic backup is finished you can remove the old unencrypted backup files. Finally, you have to wipe the free space to destroy any traces of the old unencrypted backup files.
| Encrypting a currently used external hard drive such that it can be updated with rsync? |
1,446,884,727,000 |
Windows allows the selective encrypting of certain files or folders. I currently have a Windows folder that is set to "encrypt contents to secure data". (The Windows partition is NTFS.)
If I mount this drive under Linux, is there anyway to decrypt the contents of the directory so that I can read the files without having to reboot into Windows?
|
According to the NTFS-3G FAQ, you can't read or write encrypted files:
[...] Reading and writing transparently compressed files are fully supported, but reading or writing encrypted files are not supported at the moment. [...]
So you'll need to do that from Windows at this point.
| Use Linux to read contents of Windows encrypted folder |
1,446,884,727,000 |
I'm using ext4 encryption. https://wiki.archlinux.org/index.php/Ext4#Using_file-based_encryption
Before I decrypt a directory, I can see lots of encrypted filenames in it.
I would like to copy the encrypted files so that I can decrypt them on a different machine.
I could do this with ecryptfs. How do I do this with ext4 encryption.
|
You can see encrypted & padded filenames, but you should be unable to read file contents. So trying to copy the files unencrypted will result in errors such as:
cp: cannot open 'vault/YgI8PdDi8wY33ksRNQJSvB' for reading: Required key not available
So you are pretty much not supposed to do this. The practical answer is to decrypt it, then copy it. The copy will be re-encrypted if you picked an encrypted location as the target directory. Over the network with rsync/ssh the transfer will be encrypted also. So most things work, just storing it in the cloud is probably out of the question. Filesystem specific encryption does not work outside of the filesystem.
Circumventing the read barrier is not sufficient: unlike ecryptfs where all metadata is regular files, the ext4 encryption involves metadata hidden in the filesystem itself, not visible to you, so you cannot easily copy it.
The closest I found is e4crypt get_policy, e4crypt set_policy which allows you to encrypt a directory with an existing key without knowing the actual key in clear text. But it only works for empty directories, not for files.
You can also encrypt a vault directory, populate it with files, then hardlink those files to the root directory, then delete the vault directory. You end up with encrypted files (contents) in the root directory (which you are not supposed to be able to encrypt). The filesystem just knows that the file is encrypted. (Not recommended to actually do this.)
If you must make a copy anyway, I guess you can do it the roundabout way:
make a raw dd copy of the entire filesystem
change filesystem UUID
delete the files you didn't want
Otherwise I guess you'd need a specialized tool that knows how to replicate an encrypted directory + metadata from one ext4 filesystem to another, but I didn't see a way to do so with e4crypt or debugfs.
debugfs in particular seems to be devoid of policy / crypt related features except for ls -r which shows encrypted filenames in their full glory as \x1e\x5c\x8d\xe2\xb7\xb5\xa0N\xee\xfa\xde\xa66\x8axY which means the ASCII representation regular ls shows is encoded in some way to be printable.
Actual filename is [padded to and actually stored in the filesystem as] 16 random bytes, but regular ls shows it as 22 ASCII characters instead. Copying such a file the traditional way would create a file stored as its ASCII character representation when you really need to store it as random bytes. So that's just bound to fail in so many layers.
tl;dr if there is a way to do it then I don't know about it :-}
| Copying ext4 encrypted files |
1,446,884,727,000 |
I need to encrypt and decrypt a password using bash script. For that, I'm using openssl.
The decryption is needed because I'm moving the password between hosts.
The weird thing is it looks like the encryption has an expiration time.
To encrypt (not on bash script):
echo P@$$word| openssl enc -aes-128-cbc -a -salt -pass pass:pass_key
to decrypt (on bash script):
dec_password=$(echo -n $1 | openssl enc -aes-128-cbc -a -d -salt -pass pass:pass_key)
if I'm doing the encryption and then running the script it works perfectly.
However, if I'm doing the encryption and in the next day running the script for decryption it fails with the error:
error reading input file
Not sure if time is related but that's the only variable that changed.
Any ideas? Thanks
|
The error you have after waiting some time to decrypt the password, and you mentioning it seems the method "has an expiration time" is because the random generated salt varies over time. (e.g. it will be different every day)
When encrypting, the 1st characters of the encrypted password are the salt used when encrypting with a salt; you should use the same salt for decrypting.
Be aware that if trying to encrypt without salt, in MacOS/ older? openssl versions you have to use the -nosaltkeyword; openssl generates and uses a salt by default.
So to encrypt without salt, you need to do:
echo P@$$word| openssl enc -aes-128-cbc -a -nosalt -pass pass:pass_key
However, when storing passwords, it is bad practice decrypting them to compare them with candidate passwords; later on for comparing scripts you do not decrypt them:
what you do to compare passwords is encrypting a password to check with the same salt (if using salt), and compare the encrypted strings to see if they match.
If it is for forwarding passwords between systems and not storing them, using salt is not so essential, however keep in mind it helps keeping it more secure.
However in case you have strong security needs about encryption strenght, OpenSSL is known for having a weak encryption strength and GnuPG is stronger than openSSL for encrypting.
| encrypt/decrypt string with openssl error |
1,446,884,727,000 |
How do I format LUKS encrypted disk if I don't know the passphrase?
I recently switched my HDD for a new SSD disk in my laptop and now when I connect the old HDD externally I can't mount disk event with the right passphrase (I assume I am doing something wrong at this point). However I want to format that disk and use it as regular external HDD, so is there a way how to do that? All tutorials I've found requires the knowledge of passphrase.
This is what I get during unlocking
Error unlocking /dev/dm-6: Command-line `cryptsetup luksOpen "/dev/dm-6"
"luks-5a73e3e1-6b40-415f-8c40-ca14faecc7cb" '
exited with non-zero exit status 1: .
|
If you want to overwrite the data of the encrypted disk with non-encrypted data anyway (i.e. you don't care about the current contents), you don't have to unlock the drive/partition first.
If the partition has a particular uncommon partition type, you might want to change that, but it is not necessary. You can just use mkfs.ext4 (or any filesystem type you prefer) on the partition which contains the LUKS encrypte partition.
| Formatting LUKS encrypted disk |
1,406,962,112,000 |
Using tar in multi-volume mode relies on a ENOSPC error to detect the end of the first tape and prompt the user for the next tape.
To simulate this behaviour consider the following example by writing to /dev/full
tar -cvf - --multi-volume . > /dev/full
as expected results in
[...]
Prepare volume #2 for ‘-’ and hit return:
A problem arises when piping the output of tar through an encyption program like aespipe or gpg
tar -cvf - --multi-volume . | gpg -c --batch -q --passphrase 123 > /dev/full
which causes gpg to exit with code 2
gpg: [stdout]: write error: No space left on device
gpg: [stdout]: write error: No space left on device
gpg: filter_flush failed on close: No space left on device
The ENOSPC is obviously not propagated to tar, which isn't made aware of the specific errno. Is there a way to catch the error from gpg and "re-raise" the ENOSPC error to tar with a bash script?
For example, using tar with a named pipe results in a broken pipe once gpg fails and tar subsequently exists with SIGPIPE 141 -- however ENOSPC still has to be signaled to tar in some way instead of the broken pipe error.
I would like to avoid the workaround of specifying a fixed tape size.
I am also aware of using mbuffer to handle tape spanning, which is undesireable because tapes can not be extracted individually.
EDIT: I just realized this is going to be a lot more complicated, as the data that has already left tar and was in the buffer when ENOSPC was encountered is most likely lost. Though most tape driver implementations allow another write operation after that, gpg and aespipe include no retry logic to save the data in the buffer.
EDIT 2: Further research shows that star on FreeBSD with the -compress-program option to perform the encryption in conjunction with -multivol and new-volume-script=... raises the error
star: Operation not permitted. Cannot lock fifo memory.
star: Can only compress files
when writing to a device instead of a file. So that's a dead end too.
|
It's not possible to propagate write errors back through a pipeline
And even if it were possible with some kind of hack, the pipes are buffering and by the time the pipe reader tries to "signal" the pipe writer, the latter could've already written the data which is causing the error further down the line, already got a successful status (>0) and updated its state accordingly. For it to work, the writing process would have to go back in time. On top of that, the pipe reader itself may do its own buffering and state keeping which would go out of sync.
The only way out is for tar to call the encryption routines directly, instead of passing the data through some kind of channel. Instead of modifying its source code and recompiling it, that could be done by monkey/live patching it with a LD_PRELOAD hack which overrides the write() library function and processes the data before passing it to the original write().
How to simulate ENOSPC with a LD_PRELOAD hack
This will cause an write to fd 1 (stdout) to fail with ENOSPC as soon as it tries to write more than 40960 bytes to it, after which it resets the counter and succeeds again, etc.
If you want it to work with tar -cf filename, instead of tar -cf -, you should probably change the fd == 1 test to fd != 2.
$ cat <<'EOT' >enospc.c
#define _GNU_SOURCE
#include <unistd.h>
#include <dlfcn.h>
#include <err.h>
#include <errno.h>
#define MAX 40960
ssize_t write(int fd, const void *b, size_t z){
ssize_t w;
static typeof (write) *o_write;
static size_t count;
if(!o_write) o_write = dlsym(RTLD_NEXT, "write");
if(fd == 1 && count + z > MAX){
count = 0;
errno = ENOSPC;
return -1;
}
w = o_write(fd, b, z);
if(w > 0) count += w;
return w;
}
EOT
$ cc -Wall -shared enospc.c -o enospc.so -ldl
$ seq -f 'n foo%04g.tar' 1 10000 |
LD_PRELOAD=./enospc.so tar -M -cf- /etc/X11 > foo0000.tar
tar: Removing leading `/' from member names
Prepare volume #2 for ‘-’ and hit return: Prepare volume #3 for ‘/tmp/foo0001.tar’ and hit return: Prepare volume #4 for ‘/tmp/foo0002.tar’ and hit return: Prepare volume #5 for ‘/tmp/foo0003.tar’ and hit return: Prepare volume #6 for ‘/tmp/foo0004.tar’ and hit return: Prepare volume #7 for ‘/tmp/foo0005.tar’ and hit return: Prepare volume #8 for ‘/tmp/foo0006.tar’ and hit return: Prepare volume #9 for ‘/tmp/foo0007.tar’ and hit return: $
$ ls foo000*
foo0000.tar foo0002.tar foo0004.tar foo0006.tar foo0008.tar
foo0001.tar foo0003.tar foo0005.tar foo0007.tar
| End of tape detection (ENOSPC) in tar multi-volume mode with pipes for encryption |
1,406,962,112,000 |
I need to encrypt an SSD drive and I have opted to use dm-crypt. This is not something I do on a regular basis.
So far I have successfully cleared the memory cells of my SSD with the ATA secure erase command. I have also filled the entire disk with random data using:
dd if=/dev/urandom of=/dev/sdx bs=4096 status=progress.
My question is in regards to the final step, which is encrypting the devices (my partitions) with the cryptsetup utility.
Since I’ve already filled my entire disk with random data, will I need to refill my partitions with random data after creating and encrypting them? In other words, will the random data that I generated with dd still reside inside of the encrypted partitions that i create?
|
dd if=/dev/urandom of=/dev/sdx bs=4096 status=progress
This command will overwrite the entire drive with random data. That random data will stay there until you write other data, or secure-erase, or TRIM.
In other words, will the random data that I generated with dd still reside inside of the encrypted partitions that i create?
Normally this is the case.
However, it's not always obvious when TRIM happens. For example, mkfs or mkswap/swapon silently imply TRIM and you have to use additional parameters to disable it. I do not know if partitioners picked up the same idea and TRIM newly created partitions. If using LVM instead of partitions, note that lvremove / lvresize / etc. does imply TRIM if you have issue_discards = 1 in your lvm.conf. Other storage layers such as mdadm support TRIM as a simple pass-through operation.
cryptsetup open by default does not allow TRIM unless you specify --allow-discards, however some distributions might choose to change those defaults.
After all, it's very unusual to random-wipe SSD for encryption. The only use case I can think of is getting rid of old data while not trusting the hardware to do this for free when you TRIM or secure-erase.
Even with encryption, it's normal for free space to be visible on SSD. Most people will want to use TRIM weekly/monthly to avoid possible performance degradation in the long term, so distributions might follow that trend and use allow-discards on encrypted devices by default.
Once trimmed, your overwriting with random data was for naught.
But as long as you are in control, and disable TRIM in everything you do, the random data will stay.
| Filling SSD with Random Data for Encryption with Dm-Crypt |
1,406,962,112,000 |
I have a system (VM, actually) with Linux Mint 15 on it. The disk is encrypted, but I remember that password -- just not the password for my account. I've tried changing the command in GRUB from ro to rw init=/bin/bash, per guides online, but that doesn't seem to play nicely with the disk encryption. Is there a way to decrypt the disk, then drop straight to a root prompt (in order to use passwd)?
|
This is actually way easier than you might think. Here's how you do it:
Boot into a Live CD.
Decrypt and mount your partition on your hard disk. If you have a couple of partitions that all get mounted at boot, you will need to mount all of those, and in the correct order. Note that while you can get away with it this time, usually this includes bind-mounting /proc and /dev into the hard drive mountpoint.
I won't go into how to do this, since I forget, but you should be able to find how to online (just search for "mount an encrypted partition linux" or something), or ask a new question here.
If you haven't already opened a terminal, open one, and type chroot /path/to/your/encrypted/drive bash, where /path/to/your/encrypted/drive is where you mounted the hard drive partition.
chroot stands for "change root". Root here is referring to the root of your directory tree, not the root account. Basically any program that you run from now on will see the hard drive, not the CD, as the root of the filesystem. bash at the end tells chroot what program to run from the new root - so you're running bash from your hard drive, not from the CD. bash will think it's executing from something like /usr/bin/bash, but in reality it'll be executing from /path/to/your/encrypted/drive/usr/bin/bash.
If my garbled explanation was unreadable, here's the Wikipedia article and the manpage.
Run passwd.
Type exit to get out of the chroot and reboot out of the CD and into your hard drive.
Profit.
| Resetting password in Linux Mint when disk is encrypted |
1,406,962,112,000 |
I'm using WeeChat for quite a while on different machines now. All instances are using the same settings over and over again. When I connect, everything is fine, like this output from WeeChat, just some certificate warnings, but I usually ignore them (as I'm connecting to my own server without any valid certs):
11:39:19 fnd -- | irc: connecting to server ***.***.***/* (SSL)...
11:39:19 fnd -- | gnutls: connected using 1024-bit Diffie-Hellman shared secret exchange
11:39:19 fnd =!= | gnutls: peer's certificate is NOT trusted
11:39:19 fnd =!= | gnutls: peer's certificate issuer is unknown
11:39:19 fnd -- | gnutls: receiving 1 certificate
[...]
11:39:19 fnd =!= | gnutls: the hostname in the certificate does NOT match "***.***.***"
11:39:19 fnd -- | irc: connected to ***.***.***/* (*.*.*.*)
11:39:19 fnd -- | Welcome to the freenode Internet Relay Chat Network ***
[...]
Now, right after a successful connection, suddenly I get the following error disconnecting me from server:
[...]
11:39:19 fnd =!= | irc: reading data on socket: error -24 Decryption has failed.
11:39:19 fnd -- | irc: disconnecting from server...
11:39:19 fnd -- | irc: disconnected from server
11:39:19 fnd -- | irc: reconnecting to server in 10 seconds
I'm using ArchLinux with WeeChat 0.4.1.
[user@machine ~]$ weechat-curses -v
0.4.1
[user@machine ~]$ uname -a
Linux machine 3.9.9-1-ARCH #1 SMP PREEMPT Wed Jul 3 22:45:16 CEST 2013 x86_64 GNU/Linux
SSL is on, SSL-Keysize is 1024 and SSL-Verify is off. The server which I'm connecting to is a bouncer (ZNC) instance. But the same WeeChat settings are working on other machines.
How to solve this? What's the problem here?
|
I asked the guys at #weechat and they know this issue. It's a major bug in GnuTLS 3.2.2, it also breaks other stuff like webkit, wget, etc.
Downgrading (or waiting for a fixed version) fixed this issue, it's not a weechat problem.
Follow this issues:
https://bugs.archlinux.org/task/36207
https://bugs.archlinux.org/task/36212
| WeeChat decryption fails while reading from data socket |
1,406,962,112,000 |
I have a computer running OpenSUSE 12.1, 64-bit, default install.
How it works currently:
I turn on the computer
It goes through the boot process
At some point during boot, I am asked for password to decrypt an encrypted partition
The problem is there is a timeout on this prompt, so I have to sit next to computer and pay attention to what is going on.
How can I disable that timer, so I could for example turn the computer on and go away, and then return after 1 hour and still see this prompt?
|
Have a look at this Opensuse forum thread. It reveals that it's an issue with systemd's default unit timeout and not respecting the timeout setting in crypttab.
It also provides a workaround -- letting the initrd take care of it, with an /etc/crypttab entry like this (i.e. adding the initrd)
cr_sdb3 /dev/disk/by-id/ata-SHORTENED-part3 none initrd
followed by rebuilding with mkinitrd.
Additionally, the author of the linked post filed a bug report.
| How to disable timeout of password prompt for partition decryption during boot? |
1,406,962,112,000 |
Always when I install Linux OS (e.g. Ubuntu), there is a possibility to encrypt the home directory. I was asking myself why is this useful.
Is it good in the case when my harddrive is corrupted and I have to go to my manufacturer and let the harddrive at him for about a month for the reparation or exchange? He can't decrypt my data? Naturally, I can't bring the harddrive to him in this state.
What are the disadvantages of encryption of home directory when using it every day?
I was inspired by the question How do I get rid of a hard disk without exposing my source code?
|
What you described is the use case of using home encryption. There is a lot of sensitive data stored in other areas, so encrypting home doesn't really give you much protection, but well, it's better than nothing.
The disadvantages are kind of obvious:
if you forget your password you will never get access to your data
you have to enter the password every time you log in
if you don't have a modern Intel CPU with the AES instruction, you will notice a big performance hit
recovering corrupted filesystem can be harder with encryption (two layers that can get corrupted instead of one)
| Encryption of home directory for securing data after harddisk corruption |
1,406,962,112,000 |
I've recently been teaching myself about the BSDs and decided to pick up a NetBSD VPS. I don't always log in to this box every day (it's not actually doing anything that important), but I'd still like to monitor root's mail. To that end, I started looking into how to forward root's mail to an external account. I learned a little about the /etc/aliases file, and it looks like I might be able to build up a pipeline to do this for me, but I'm treading into unfamiliar territory.
Is there a tutorial that covers this sort of thing? Is it even a good idea?
Thanks.
|
You could create a normal user, e.g. juser, and add it to the /etc/aliases file on the right hand side of the root entry.
For normal forwarding of root-mail you would just create a .forward (which contains your external e-mail address) in the home directory of juser.
Regarding encryption you can use a MDA (mail delivery agent for that), e.g. procmail and for that. Instead of a .forward you have to create a .procmailrc file in the home directory of juser in that case.
Via .procmailrc you can pipe a message (header/body) through an external program, e.g. a simple script that basically contains some gpg command. And with the right rule at the end of the procmailrc, you can forward the (processed) message to your external e-mail address.
| How to automatically encrypt, sign, and forward root's email? |
1,406,962,112,000 |
i am trying to do arch(or any distro)-install with encrypted boot partition(lvm - uefi) during installation. i am trying really hard to get it to working but i get this error in picture below. i searched a lot but i didn't get anywhere i believe it is possible because of this option (GRUB_ENABLE_CRYPTODISK=1) in grub config
Inside arch-chroot /mnt <<
EFI Partition is FAT 32
Rest is EXT4>>
|
grub-install is expecting to find /boot, but cannot, because according to your lsblk, it's at /mnt/boot... so you aren't chrooted into the new installation at this time.
But I agree with Sheldon: having the EFI System Partition (ESP for short) inside a Linux encrypted partition won't work.
The UEFI firmware wants to find a readable FAT partition (optimally FAT32, but newer UEFI releases accept other forms of FAT too) which satisfies one of the following conditions:
either its PARTUUID matches the value written into the UEFI boot NVRAM variable (accessible in Linux using efibootmgr) and the partition contains the boot file whose pathname is specified in that NVRAM variable (e.g. \EFI\Arch\grubx64.efi or \EFI\Arch\shimx64.efi if using the Secure Boot compatibility shim)
or the partition contains a file whose pathname can be expressed in Windows-style as \EFI\BOOT\BOOTx64.efi (= removable media/fallback boot path)
With your current configuration, the firmware will see the sda1 partition, but since its contents are apparently random nonsense (because encrypted) the firmware won't be able to proceed with the boot at all. Unless your UEFI firmware includes support for the exact disk encryption scheme you're planning to use, the ESP partition must remain unencrypted: normally the UEFI firmware cannot boot from an encrypted ESP partition. This should not be a major problem in practice, as ESP should contain standard bootloader components only. If Secure Boot is in effect, the firmware will check the validity of the bootloader's cryptographic signature.
If the UEFI firmware implementation allows you to change the Secure Boot keys, you could replace the factory default keys with keys you've generated yourself, and then the system would accept only bootloaders signed by your key.
ArchWiki has this example configuration for full-disk encryption with UEFI boot.
+---------------------+----------------------+----------------------+----------------------+----------------------+
| BIOS boot partition | EFI system partition | Logical volume 1 | Logical volume 2 | Logical volume 3 |
| | | | | |
| | /efi | / | [SWAP] | /home |
| | | | | |
| | | /dev/MyVolGroup/root | /dev/MyVolGroup/swap | /dev/MyVolGroup/home |
| /dev/sda1 | /dev/sda2 |----------------------+----------------------+----------------------+
| unencrypted | unencrypted | /dev/sda3 encrypted using LVM on LUKS1 |
+---------------------+----------------------+--------------------------------------------------------------------+
It also includes the BIOS boot partition for maximum compatibility, but if you plan to boot in UEFI native style only, you can omit the BIOS boot partition and all steps related to it. In this layout, ESP is mounted as /efi in the resulting installation (and it would be /mnt/efi in the situation of your screenshot, if it existed there) and /boot is not a separate filesystem, but just an ordinary directory within the root filesystem.
| Grub install with encrypted Boot partition |
1,406,962,112,000 |
If I only have an SSH pubkey, how can I encrypt an ex.: IP address (so a short string), only using the ssh pubkey?
For decryption, the other party would have the pair of the pubkey, so the private key, with which it can decrypt the string.
|
Here is one way to do that:
First of all you should install the latest versions of OpenSSL and OpenSSH.
Before we can encrypt the plaintext with our public key, we must export our public key into a PEM format suitable for OpenSSL's consumption
openssl rsa -in ~/.ssh/id_rsa -pubout ~/.ssh/id_rsa.pub.pem
then you can encrypt:
cat plain.txt | openssl rsautl -encrypt -pubin -inkey ~/.ssh/id_rsa.pub.pem > cipher.txt
rsautl: RSA Utility
-encrypt: key indicates we are encrypting from plaintext to cipher text
-pubin: flag indicates we are loading a public key from -inkey [public key file].
and for decrypt:
cat cipher.txt | openssl rsautl -decrypt -inkey ~/.ssh/id_rsa
| How to encrypt a string with my SSH pubkey? |
1,406,962,112,000 |
I'm trying to accomplish encrypting my OS w/ LVM on RHEL 7.2 and have it boot without entering a password by using a key on an unencrypted partition.
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home rhel -wi-ao---- 22.35g
root rhel -wi-ao---- 27.94g
swap rhel -wi-ao---- 1.86g
I created an unencrypted mount point /media where I generated a key using the following commands:
dd bs=512 count=4 if=/dev/urandom of=/media/fdekey iflag=fullblock
I added the key with my passphrase as follows:
cryptsetup luksAddKey /dev/mapper/rhel-root /media/fdekey
cryptsetup luksAddKey /dev/mapper/rhel-home /media/fdekey
cryptsetup luksAddKey /dev/mapper/rhel-swap /media/fdekey
I then edited /etc/crypttab to add the key:
luks-b7ac522a-52fd-4540-917d-3454dafdf7dc UUID=b7ac522a-52fd-4540-917d-3454dafdf7dc /media/fdekey luks
luks-ad431e02-a49d-4ba3-bf9c-06e7a9f9a7f9 UUID=ad431e02-a49d-4ba3-bf9c-06e7a9f9a7f9 /media/fdekey luks
luks-a3819933-91d5-434b-bb6c-42d273bb34c2 UUID=a3819933-91d5-434b-bb6c-42d273bb34c2 /media/fdekey luks
Modified /etc/dracut.conf
# dracut modules to omit
omit_dracutmodules+="systemd"
# dracut modules to add to the default
add_dracutmodules+="crypt lvm"
Modified /etc/default/grub:
rd.luks.key=/media/fdekey:LABEL=media
Generated grub:
grub2-mkconfig -o /boot/grub2/grub.cfg
Generated initramfs:
dracut -fv
output of df -h:
Filesystem Size Used Avail Use% Mounted on
/dev/dm-3 28G 876M 28G 4% /
devtmpfs 9.6G 0 9.6G 0% /dev
tmpfs 9.6G 0 9.6G 0% /dev/shm
tmpfs 9.6G 8.4M 9.6G 1% /run
tmpfs 9.6G 0 9.6G 0% /sys/fs/cgroup
/dev/sda2 4.5G 19M 4.2G 1% /media
/dev/sda1 950M 133M 818M 14% /boot
/dev/dm-5 23G 33M 23G 1% /home
tmpfs 2.0G 0 2.0G 0% /run/user/0
output of fdisk -l:
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a0a6e
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1953791 975872 83 Linux
/dev/sda2 1953792 11718655 4882432 83 Linux
/dev/sda3 11718656 121114623 54697984 8e Linux LVM
Disk /dev/mapper/rhel-root: 30.0 GB, 30001856512 bytes, 58597376 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-swap: 2000 MB, 2000683008 bytes, 3907584 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/luks-b7ac522a-52fd-4540-917d-3454dafdf7dc: 1998 MB, 1998585856 bytes, 3903488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/luks-a3819933-91d5-434b-bb6c-42d273bb34c2: 30.0 GB, 29999759360 bytes, 58593280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-home: 24.0 GB, 23999807488 bytes, 46874624 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/luks-ad431e02-a49d-4ba3-bf9c-06e7a9f9a7f9: 24.0 GB, 23997710336 bytes, 46870528 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
I feel like I'm missing some step(s). Upon boot up I am still asked for the passphrase.
|
I needed to add the path to my keyfile to dracut.confand rebuild initramfs.
echo 'install_items+="/media/key"' >> /etc/dracut.conf
dracut -fv
| RHEL: FDE w/o password - boot from key on partition |
1,406,962,112,000 |
Hmm, I would like to know what is happening with the data on the Linux swap partition when the Linux system is turned off and by the next start the Windows operating system via GRUB2 will start.
3 questions
Will Windows be able to access the data from the Linux swap partition if Linux is turned off the right way?
Will Windows be able to access the data from the Linux swap partition if Linux is turned off the wrong way (hard reset)?
The swap area contains the mirror of RAM at a given time right? So, it cannot be encrypted by default, right?
|
To questions 1 and 2: Yes, Windows is able to access the data from the swap partition. But is not able to interpret these data by default. So you could analyse the partition using some tools, but Windows would not display any data by default.
To question 3:
The swap partition (or file) does not contain a mirror of the RAM, it contains the data that didn't fit into the RAM any more and/or weren't accessed for a specific time.
It can be encrypted be default, for example the *ubuntu system can encrypt their swap partitions using logical volumes.
See also this tutorial as an example:
Arch Linux – Swap encryption
(Not really sure about it: Modern system should be able to encrypt their swap partitions and hibernate-to-disk.)
| What is happening with the Linux swap partition data when running Windows via dual-boot |
1,406,962,112,000 |
I'm running Linux on my Laptop and wish to protect my data in case the machine is lost or stolen.
I've configured an encrypted ArchLinux environment and have everything working the way that I want. Now I wish to add suspend to disk functionality, which necessitates swap space. If I allocate swap space as a file on the root filesystem (which is already encrypted), does that swap file still need to be encrypted? Please explain why or why not.
|
If the root filesystem is encrypted, all files written to the filesystem, whether they be plain text files or swap files will all be encrypted.
| Is it necessary to encrypt a swap * file * if it will reside on an encrypted root filesytem? |
1,406,962,112,000 |
I have a partition that contains all my personal stuff, which is mounted at boot under /home/myuser/foo. I would like to synchronize it on the cloud via Dropbox or Copy.com, but I don't trust them, so I have to encrypt the data in some way.
As I understood, it creates a "volume" when opened, and the data is clear only in ram, which is great. The problem is that this volume is seen as a single file by the Dropbox/Copy.com client, so when I change something, as little as a text file, it will attempt to upload again the whole encrypted "volume".
There is some way to encrypt my data and upload it in security?
|
Instead of encrypting a whole volume, which is the TrueCrypt, LUKS and loopback approach, you can also encrypt the individual files you store in the cloud. Doing that manually with pgp before copying the file to your cloud synchronized directory is one way, but a bit cumbersome.
EncFS may be a solution for you instead. It transparently encrypts files, using an arbitrary directory as storage for the encrypted files.
Two directories are involved in mounting an EncFS filesystem: the source directory, and the mountpoint. Each file in the mountpoint has a specific file in the source directory that corresponds to it. The file in the mountpoint provides the unencrypted view of the one in the source directory. Filenames are encrypted in the source directory.
| Dropbox/Copy.com & Truecrypt |
1,406,962,112,000 |
I'm actually trying to setup LUKS on a Red Hat 9.2 Server.
Here is the problem : I can't do yum install cryptsetup-luks or dnf install cryptsetup-luks.
When I try to use one of these command I have the following output :
no match for parameter: cryptsetup-luks
error: unable to find a match: cryptsetup-luks
I don't really understand why, because I'm following procedures from IBM and Official Red Hat documentation. The links of these procedures are below :
https://www.ibm.com/docs/en/order-management-sw/10.0?topic=considerations-encrypting-data-partitions-using-luks
https://access.redhat.com/documentation/eng-eng/red_hat_enterprise_linux/9/html/security_hardening/encrypting-block-devices-using-luks_security-hardening#options-for-data-protection-during-luks2-re-encryption_encrypting-block-devices-using-luks
I think the problem can comes from my repos because my repolist is as follow :
Local-AppStream
Local-BaseOS
Tuleap
epel
epel-cisco-openh264
remi-modular
remi-safe
Anyone can explain me what am I doing wrong ? Or if I didn't see an important thing ?
I tried to check if any other encryption solution was present on my system regarding which packages are installed that could be apparented to this. But even if I'm new on this activity, I didn't see any package that could be blocking me.
Thanks
|
The package is called just cryptsetup. It used to be called cryptsetup-luks way back in RHEL 6 but since RHEL 7 it's just cryptsetup and it's in the BaseOS repository so you don't need any other extra repository.
| How to install cryptsetup-luks |
1,406,962,112,000 |
I used to use openssl aes-256-cbc, but the problem I have with this is when I try to decrypt in a different version of the distro it fails, as if it depends also on some internal key or something, instead of depending solely on the password. So I have to keep a different encrypted file for each version of the distro, which is annoying and bad.
Any suggestions?
|
You could use gpg -c file.txt, since GPG supports encrypting a file with a passphrase and symmetric encryption.
The issue with openssl is most likely either a version mismatch or you're simply not using the right command. You could pull down the most recent code for openssl command line utility off github and compile it from source on all the computers, so they all have the same version.
You could also try manually specifying the Key Derivation Function parameters for openssl, for example: openssl enc -aes-256-cbc -pbkdf2 -salt -iter 100000 -in archive.tar.gz -out encrypted.tar.gz.ossl, which might resolve the issue without compiling from source (I'm not sure, but a newer version might use a more secure KDF by default, which causes decryption errors unless you manually specify the proper arguments)
| How to encrypt a text file in a portable manner based solely on a password? |
1,406,962,112,000 |
I'm using a dual boot system with Windows 8 and Fedora 31 KDE on my PC.
I've encrypted my external hard disk with VeraCrypt in Windows.
Windows recognizes this external hard drive and I can unlock the encrypted hard disk with VeraCrypt on Windows.
My problem is that Fedora does not recognize the encrypted hard disk. Although the hard disk is supplied with power, it does not appear in the device list.
What can I do to solve this problem?
|
When your hard disk is connected, open a command line and type sudo blkid to list all available partitions. Graphically, you can see them with GParted.
Locate the partition that you wish to mount.
Once you know know it (something like "/dev/sdc1"), open Veracrypt GUI, choose a slot for mounting, and provide the path to the encrypted volume in the "Volume" field. For example, here I would mount /dev/sdc1 on the 5th Veracrypt mount point:
Click "Mount", provide the password / PIM / keyfile in the new popup as needed. It should make the job.
You can achieve the same result with command line :
veracrypt -t /dev/sdc1
You will then be prompted for other options : password, keyfiles, PIM...
You can also specify a mountpoint if you don't wish to take the first available Veracrypt mountpoint:
veracrypt -t /dev/sdc1 /mnt/veracrypt5
Please note that /mnt/veracryptX is where Veracrypt mounts volumes in openSUSE. It might differ for Fedora...
| Encrypted external hard disk not recognized |
1,406,962,112,000 |
I've actually just started dabbling in the raspeberry pi but no stranger to hacking around these controllers. Having said that, my knowledge is lacking in a few areas.
A little about what I want to try to achieve:
I am fooling around with one of the pi cameras and the picamera module for raspberry Pi. I'm trying to record stuff at the highest quality- right now I guess 1080p at 30fps. I want to write/record these videos to a usb stick plugged into the raspberry pi, which i would also like to be encrypted due to the fact that I will be removing and plugging that usb stick into my computer (I use both PC and Mac) to view/modify these movie files. Then I can remove those files from the usb stick as I need to and then replug into the Pi and record more, etc.
I don't need supreme protection. I'm more or less looking for an easy user experience at the expense of top notch security as I've read that means keeping some important logins/passwords in a file on the drive. I'm ok with that as long as the info is indeed encrypted from the casual peeker.
Some Questions:
Assuming I dont want to have to allocate space beforehand to this encrypted directory/drive, thus does that really leave me only with
ecryptfs or encfs? Can i use gpgdir?
Would I be recording the video to a directory outside of the encrypted directory/usb, then once that file has completed
recording, automate the encryption into the encrypted directory? Or
is it possible to just write into the encrypted directory?
Can this encrypted usb stick be auto mounted? EDIT: I think I can glean on how to do this using this method.
I saw a neat tutorial that seemed to do what I wanted using TrueCrypt and the Pi though truecrypt is no longer supported.
Thanks for any help!
EDIT:
Made it through cross referencing this but getting a few errors on boot:
...
starting early crypto disks
usbdrive_crypt: keyfile not found
usbdrive_crypt (invalid key)
...
starting remaining crypto disks
usbdrive_crypt: keyfile not found
usbdrive_crypt (invalid key)
...
checking file systems...
...
open: no such file or directory
...
fsck died with exit status 6
...
mounting local filesystems..mount: special device /dev/mapper/usbdrive_crypt does not exist...
crypttab file:
usbencrypted UUID=xxxx /boot/key_luks luks
fstab file:
/dev/mapper/usbencrypted /mnt/usbdrive vfat defaults 0 2
|
I would suggest using dm-crypt. This is a block level encryption system, support in kernel. This way, all encryption is handled OS/Kernel level, and is transparent to the user. At a high level:
Wipe the disk with fdisk, and create a single partition spanning the entire disk (henceforth referred to as /dev/sdX1)
Create a new crypt-luks volume
cryptsetup luksFormat /dev/sdX1
Map it
cryptsetup open /dev/sdX1 usbdrive
Create a filesystem on the device
mkfs.ext4 /dev/mapper/usbdrive
Mount it
mount /dev/mapper/usbdrive /mnt
To automate this, there are two approaches. One is to use /etc/crypttab and let systemd take care of it. A second approach would be a custom udev that assigns a consistent name and mounts the volume when the key is inserted
| auto mount encrypted USB |
1,406,962,112,000 |
I have such boot sequence: system boots from external disk, right after start it asks about password for LVM encrypted partition (which holds /root and /home), I enter it, the partitions are mounted, boot continues, everybody happy.
This was openSUSE 11.4. I upgraded to 13.2 and now the boot loader (grub) does not ask about any password, it believes that LVM mount point is regular, accessible partition, and after some delay it simply states this partition is not present (/dev/my_lvm/root).
I kept backup of old /boot and I compared device map of grub, and menu list, both version (previous, from OS 11.4) and current looks the same (actually analogous, because now grub has current and previous menu entries).
So how to make grub to ask me about the password, as before?
Update Using the info provided in the thread about boot loaders -- https://askubuntu.com/questions/107440/how-to-check-what-bootloader-my-system-is-using -- I have GRUB version 0.97 in my boot partition used.
|
I had a similar problem, installing openSuSE 13.2 x86_64 from scratch, using a boot partition and an encrypted LVM containing root and swap. (Side note: It's not easy to do that actually since when creating an lvm partition the installer UI will not even let you chose "encrypt this device", you can "ungrey" the checkbox however by first chosing "format partition" with anything else but btrfs, then go back to "do not format this partition" and selecting lvm, the checkbox is now clickable and it also really DOES encrypt it... kinda buggy UI but the logic works).
So, here's how i booted my system again after 5 hours of reinstallations etc:
In grub, select other boot options and go "failsafe". You get a more down-to-earth boot with the typical oldskool-text scrolling down about what's happening... It will stop at some point and ask for the password for the disk (since it is multithreaded the prompt might actually not be the last line). Once you start typing the prompt reappears and you see * for each password letter entered. Note that contrary to 13.1 where only US keyboard layout was supported at the password prompt, the password prompt now uses the keyboard layout selected at installation time (or in yast presumably, if you ever changed it after installation).
So that's how I booted it, then I installed all updates and rebooted (STILL same problem!), got it up via failsafe again and went to YaST -> Boot loader.
There, I removed the "splash=silent" option from the "regular" boot entry. Also, I do not know if it matters, but I am using normal GRUB2 not the GRUB2uefi, however, that will only work if your bios supports a non-uefi setting.
So this is not a fix (you do not get the graphical password prompt back) but you can boot with the "normal" boot entry.
| How to make grub mount encrypted LVM partition |
1,406,962,112,000 |
i'm new and i hope to find an answer here. Please tell me, if you need more information.
I have an disk encryption for my home partition on Linux 4.13.0-43-generic x86_64 (Ubuntu 16.04.4 LTS).
Today when I started the laptop, I got the message, that my disk is full and there is no available space any more. With the disk usage analysis I saw, that the encryption directory (/home/.ecryptfs/bianca/.Private) is completly full - the other partition have enough space.
I did not find any answer by Google, but I would like to know, if there may be encryption files, which won't be needed any more because they may be outdated or old or anything? If yes, it is possible to remove these files or directories in this directory? Is there any tool, that can delete files, if they are not used any more?
Or do you have any other recommendation, what I can do?
It would be glad, if someone made already experience with this and can share it with me.
Thank you in advance.
Bianca
edit:
Output of lsblk:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 465,8G 0 disk
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 465,3G 0 part
│ ├─ubuntu--mate--vg-swap_1 253:1 0 15,7G 0 lvm
│ │ └─cryptswap1 253:2 0 15,7G 0 crypt [SWAP]
│ └─ubuntu--mate--vg-root 253:0 0 449,6G 0 lvm /
└─sda1 8:1 0 487M 0 part /boot
|
/home/.ecryptfs/bianca/.Private contains the encrypted versions of all your home files, when you're logged in they're decrypted on-the-fly to your home (~ or /home/bianca). It should be approximately the same size as your home when you're logged in. Delete (or backup/move) some files out of your home, not directly from /home/.ecryptfs/bianca/.Private since it's probably not clear which home files they really are.
Disk Usage Analyzer / baobab is a tool I like, or just du (there are some commands to make it more readable & sorted, a web search or man has more info)
| Disk encryption with ecryptfs - full disk |
1,406,962,112,000 |
Basic setup:
- Operating System: CentOS 7 (64 bit)
- Grub 2
- separate boot partition with ext4
- luks encryption (aes-xts-plain64:sha512) on two disc partitions which both need to be unlocked by password at boot time
- after being unlocked both partitions are mounted on / as raid1 btrfs filesystem
Right now I am looking for a clean strategy to get remote access during boot time to unlock both partitions.
On a Raspberry Pi 2 I am already using Dropbear to do this and most of the threads I found seem to favourite this option for bigger systems too. Even though on bigger systems nobody cares about the bootloader resources needed.
Question:
From my understanding on a CentOS 7 Grub2 (clean installation) I already have an OpenSSH service running by default. Why do I need to install dropbear then if openSSH and dropbear do the same job?
Shouldn't I be able to configure openSSH for grub and just paste the command:
/lib/cryptsetup/askpass "passphrase: " > /lib/cryptsetup/passfifo
diretly over openSSH?
|
So is dropbear really like the right and only choice for remote access during boot time?
I did some additional research on dracut which is used to build the initramfs image on CentOS and it shows the option "--sshkey " which needs to be combined with the module load option "ssh-client" in /etc/dracut.conf.
It looks to me again as if there already is a ssh-client at place and I do not need to install dropbear additionally. Has anyone tried this
option before? Does anyone know a good tutorial for this?
| How to use openSSH for disc encryption at boot time (OpenSSH vs. Dropbear) |
1,406,962,112,000 |
Let say that cryptsetup benchmarks gives 2 GiB/s performance. Is it per queue so on 4 core processor I could read from disk at 8 GiB/s (assuming I wasn't limited by SATA etc. and it would scale perfectly) or does it already take it into account?
|
cryptsetup benchmark only uses a single core. You can see this in top while it's running, it never goes beyond 100% of one core only.
I'm not quite sure how cryptsetup benchmark performance relates to actual performance on physical storage media; a tmpfs based loop device gives 2GiB/s according to pv, while the benchmark says 2666.5 MiB/s.
So expect slightly lower speeds than the benchmark claims.
As for scaling to multiple cores, not sure if that's a thing nowadays. I guess no since if it was I'd expect the cryptsetup benchmark to scale accordingly, too. But that's just a guess. Used to be you had to use multiple LUKS containers (and multiple readers on those containers) to get multiple cores working on encryption.
| Is cryptsetup benchmark for single or multiple queues |
1,406,962,112,000 |
I'm looking for any information regarding how secure an encrypted Linux file system is when contained in a VirtualBox virtual drive on a Windows host? Specifically I'm looking for answers to the following questions:
Does the fact it is hosted as a guest system expose the encrypted data to any new attack vectors?
Aside from the threat of key loggers on the Host OS, malware etc., when the virtual machine is turned on is there the threat of a rogue host process accessing the virtual machine's file system on the fly?
When both the Host and Guest OSes are turned off and the data is at rest on a storage device, is it any easier/harder to retrieve the encrypted file system?
|
The guest operating system runs inside the host. The host has full control over everything that the guest does and everything that goes in or out of the guest. Thus any confidential information that becomes accessible to the guest is also accessible to the host. A rogue process on the host can access everything in the guest, assuming that it has sufficient permissions to debug the VM process.
“Hiding” confidential information in a guest slightly improves security in that stupid data-collecting malware won't notice. But it does not improve security against sophisticated attackers or even against some common malware. For example typing a password into the guest is just as risky as typing it into a host process.
On the flip side, running sensitive processes in a virtual machine doesn't worsen security (except inasmuch additional complexity is inherently bad for security). Thus the answers to your questions are 1: no; 2: yes, making your scheme useless; 3: same.
If you want to gain any security from virtualization, run untrusted software with fewer privileges than trusted software, not most. Run the potentially-malware-infected programs in a virtual machine, and your sensitive files and the encryption software on the host or in a separate virtual machine. This doesn't give you absolute security, but it does provide a significant improvement. Ideally, freeze the virtual machines containing untrusted software while manipulating sensitive data on the host or another virtual machine.
| Encrypted FileSystem in VirtualBox |
1,406,962,112,000 |
I have an embedded Linux system with unencrypted kernel image and initramfs in NAND flash.
My RootFS is in SD card.
I want to encrypted some files on SD Card as my SD card is easily accessible physically.
For this I am planing to use eCryptfs.
But I want to keep the keys inside NAND flash in kernel image or initramfs.
What are my options, what is best way to secure some files on my SD card.
|
If you didn't have an initramfs, you could do it with kernel parameters. Just add a random string as kernel parameter and then use /proc/cmdline as the key for your encryption. If it's not easy to add such parameters to your boot loader, the Linux kernel has a CMDLINE config option that lets you compile it in. (Note: it is possible for kernel parameters to end up in log files and such. Whether it's suitable for your scenario depends on what is running on / writing to your SD card.)
With initramfs, of course you're free to do whatever you want. It can ask for your passphrase at bootup, or include a key, or do both using encrypted keys. It's up to you but the exact implementation depends on what your initramfs looks like without such modifications. You can look at various initramfs guides online to get an idea of how it works in principle, for example: https://wiki.gentoo.org/wiki/Custom_Initramfs
You just have to be careful to not leave an unencrypted copy of the key on the SD card itself. At the same time you should have a copy somewhere since it may be hard to get it back out of the NAND if the device ever breaks.
| eCryptfs key in kernel image or initramfs |
1,406,962,112,000 |
I'm trying to design a firmware update system for an embedded Linux system. My plan is to send an image that can be mounted on the target system, so I don't need to unpack the entire file. I also want to encrypt the image, and optionally compress it as well. Since the build system for creating this image is going to be deployed on several computers I also want the build system to require minimal amount of setup, i.e., avoid avoid requiring root privileges.
I've created a working model where I mount an image file using losetup as such:
dd if=/dev/zero of=image_file bs=1M count=10
losetup -e aes loop0 image_file
mkfs.ext2 /dev/loop0
losetup -d loop0
mount -t ext2 -o loop,encryption=aes image_file some_working_folder/
# Add files to some_working_folder
umount some_working_folder
# Send encrypted image to the target system
Now, since this is a bit cumbersome to set up on some machines, and I want to avoid creating fixed sized images. So I want to replace the losetup commands with something else. I found the command virt-make-fs, which can create a mountable image with the ext2 filesystem. So now I only need to encrypt the image file in a way that is decryptable by the linux kernel. I've tried to use OpenSSL, but I haven't been able to find the correct algorithm, or maybe I'm missing something. Does anybody know how to do this? Basically I want something like the script below.
tar -cf archive.tar some files
virt-make-fs archive.tar image.ext2
# the below command need to be fixed/replaced
openssl enc -aes192 -in image.ext2 -out image.ext2.aes
On the target system I want be able to use the following command, or at least something similar.
# The next command should be done on the target
mount -t ext2 -o loop,encryption=aes image.ext2.aes /mnt/upgrade
# work with files in /mnt/upgrade
So, just to clarify: How can I create an encrypted mountable image file without being root?
Feel free to comment if I'm trying to reinvent the wheel, or if there is some other well established solution for this problem. Even though there are better solutions, I'm still interested in the command to solve the encryption problem.
Edit: As been pointed out cryptoloop is unsecure, see http://lwn.net/Articles/67216/. So I will probably look around for another solution as well. I've found to util aespipe, which I might be able to use.
Edit 2: I've dug into the source code in the AES module of the Linux kernel, and I've concluded that it is probably the hashing of the password that is causing the problem. Both aespipe and the AES module are using an AES-256-CBC encryption. As far as I can see the linux kernel uses the given password as key, and aespipe hashes the incoming password. Since the "no root" part is very important to me I've started looking for other solutions, and my current plan is to use something like the following on the development computer:
tar -cf - file0 file1 ... | gzip -c | aespipe -e aes256 > arhive_file
And then on the target system run
rm -rf /tmp/update ; mkdir -p /tmp/update
aespipe -d -e aes256 < archive.mbl | gzip -cd | tar -C /tmp/update -xf -
|
Despiting the weak security of cryptloop according to this.
You can use usermode FS creator like: buildroot genext2fs.sh or android make_ext4fs.
with combination with aespipe tool for host creation of your encrypted image without root/superuser privilege.
But you need to patch the losetup(at least or mount) with loop-aes and activate cryptoloop (as module or builtin) for the Linux kernel of your target, to be able to mount such encrypted image directly.
The following shows how to do that in case of encrypted ext4 filesystem image (for ext2 FS you can just replace the first 2 commands with the buildroot genext2fs.sh[3]):
HOST $ make_ext4fs -s -l 512M -a data yourimage.simg folder/
HOST $ simg2img yourimage.simg yourimage.img
HOST $ cat yourimage.img | aespipe -e aes256 > yourimage.crypt
TARGET # modprobe cryptoloop #in case of cryptoloop as module.
TARGET # losetup.patched -e aes-256 /dev/loop0 yourimage.crypt
TARGET # mount -t ext4 /dev/loop0 /mnt/uncrypt
| Encrypting loopback images without using a loopback device |
1,406,962,112,000 |
I'm trying to create an encrypted data folder which could periodically take snapshots of the current state of it. The snapshot should be an encrypted one, and I should be able to take snapshots without "unmounting" the encrypted folder. Is this possible?
It seems like I could encrypt folders with EncFS, eCryptfs and gocryptfs, but I did not find wether I could take snapshots of the encrypted files while the folder is mounted. Using full disk encryption with btrfs is not an option (if it even is possible).
|
It is certainly possible, in one way or another.
I do this wiht an image file, two layers of file system (ZFS), and one layer of dm-crypt. The setup is easy to describe: Put a snapshot-capable and transaction-resistent filesystem on the image file, put a new image file on that filesystem. Make an encrypted block device of that file with cryptsetup. Create a new filesystem on that block device, and mount it at a convenient place.
The unencrypted filesystem can now be snapshot and the image file with the encrypted filesystem can be saved from this snapshot.
The file systems must be transaction-resitant, in case the snapshot happens at an inconvenient time. The unfinished transactions will be ignored and a consistent version of the files should result. There is still some technical complication with ordering if multiple files are updated though (which I'm not qualified to explain) so a database might be upset at the result. I think nilfs2 has a configuration option to use strict syncing in this case, if that is important.
In practice there are many complicated and fail-prone steps to set up and tear down this, so elaborate and fail-resistent scripts with proper testing of what has already been done/undone are recommended. I use zfs because it is easy to manage, and simplifies this task.
| Snapshottable encrypted folder |
1,522,347,185,000 |
I'd like to create one-time encrypted partition with a random key which will be wiped on reboot. I found a manual about swap encryption, but swap is just a block device which doesn't have any file system on it. Also I found full system encryption which is unacceptable, I want only one partition. Both methods are not my case.
How to create one? As far as I understand (I'm not Linux professional) I can't directly use fstab/crypttab directly because I need to format the partition after creation every time when the machine is booting up. A kind of script? Are there any pitfalls?
EDIT: Not sure if type of encryption (block/filesystem) matters so long as any saved data is encrypted. If distrib matters: Debian Stretch. TLDR: I want clean ext4 partition mounted somewhere after reboot which data is encrypted by random key.
|
Swap is actually very close to what you want — with swap, you put the swap flag in /etc/crypttab, which tells the boot up scripts to run mkswap on the block device at boot.
You basically want the same thing, but with mkfs instead of mkswap. At least here, that's already supported with the tmp[=fstype] flag. You can check the manual page (man 5 crypttab) to see what's supported on your system.
So, this should work:
some_name /dev/sdaX /dev/urandom cipher=aes-xts-plain64,size=512,tmp=ext4
and then in /etc/fstab, you'd mount /dev/mapper/some_name wherever.
BTW: An alternative is tmpfs, which keeps the data in memory. Probably swapable, though, so you'll need either no swap or encrypted swap.
| Disposable Encrypted Partition |
1,522,347,185,000 |
I have a desire to have an entire drive or volume encrypted and the volume to be write-enabled on restart of a linux system; does a method exist to provide that functionality?
What I'm looking to do is have something like a security system or dashcam write to an encrypted volume with a public key so that the volume wouldn't need to be manually opened upon startup, but wouldn't be readable without the private key. Encrypting individual files in the same fashion as they are written is an alternative.
I've, of course, searched online, including this site with no obvious solution found.
|
Filesystems simply don't work write-only; it's read-only or read-write. In a filesystem you cd somewhere and ls somewhere, all of these are read operations. If you can only encrypt (write) but not decrypt (read) you're simply not getting anywhere (with a filesystem on a block layer).
So for you, it's files or pipes, or perhaps using a block device like a tape drive (without filesystem, no arbitrary seeks/reads), or archives like tar created in a completely linear fashion that never need to re-read some old data.
If your application supports piping output, you can go with gpg or openssl or other programs that support public/private key encryption/decryption.
Generate a key just for this:
gpg --quick-generate-key myproject
(Of course, you can also use existing keys, if you prefer).
Encrypt (using echo Hello World. instead of yourprogram):
echo Hello World | gpg --batch --encrypt --recipient myproject > file.encrypted
Decrypt:
gpg --batch --decrypt < file.encrypted > file.decrypted
The machine that does the encrypting only needs the public key. On decrypting, if your private key has an additional passphrase, you will be asked to provide it (if gpg did not remember it for you).
GnuPG offers a myriad of options, this should be explained with a lot more detail here http://www.gnupg.org/ and in various Linux wikis.
Whether this is practical or not... encryption is computationally expensive, a dashcam might not be up to the task (in addition to the video workload it already has to do), ...
Supposedly there were some digital cameras that worked this way (take encrypted photos you can only view at home). Not sure why this idea is not more popular or how secure whatever method they used really was.
| Asymmetric drive encryption |
1,522,347,185,000 |
f2fs supports per-file encryption, however I can't find any resources about it.
I know about eCryptFS, LUKS and encfs, that's not the same.
|
f2fs-tools includes, as of v.1.9, a tool for encryption management in the f2fs filesystem:
f2fscrypt
The manual page includes an example that shows how to encrypt a directory (along with instructions on how to setup a f2fs filesytem that supports encryption).
The only alternative to f2fscrypt that I know of is fscryptctl (I only tried it once and it was on a ext4 filesystem but according to the author it should work equally well on f2fs).
| How to encrypt a file or a folder on f2fs? |
1,522,347,185,000 |
I would like to have a setting, where Ubuntu Server is installed and booting from a flash drive (SanDisk Cruzer Fit 8GB), with two HDDs running in RAID1 and 4 drives running with RAID0 (only 1 drive at the beginning and adding up more over time).
All drives, except for the pen drive should be encrypted and decrypted when booting up the system, thus, unplugging the pen drive would render the whole system useless. There should be a backup of the pen drive somewhere, just in case the pen drive burns down.
All HDDs should run LVM2. All the writing of files should be on the HDD and only on very rare occasions on the flash drive, since it is really slow.
If I install the Ubuntu server onto the flash drive, how do I know and prevent programs from writing a lot onto the drive? Is there a way to seize all writing at all.
Furthermore, how would I encrypt both RAID1 and RAID0 with an encryption, where the pen drive acts as the key/passphrase.
Any good reading material/tutorial is very welcome.
|
If you set up your system so that swap is on the HDDs you can run your flash boot drive as read-only and have all writes go to an overlay file system in swap. A writeup of how to do this is at https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash - use the overlayfs instructions instead of aufs. You can put any partitions where writes need to be preserved (e.g. /var) on the HDDs.
Install the system on flash as you would on any other media, set up encryption, LVM2, etc. and test that everything works. You should encrypt the pendrive also if you want full protection for the data. Then modify the initfs as described in the link and you're set to go.
| Prevent lots of writes on Ubuntu Server running from flash drive |
1,522,347,185,000 |
Tonight I decided I wanted to tweak the configuration of my Debian install on my netbook (Ideapad S10-2) to work better with the SSD I put in it.
I have done this before and never had any issues but just in case I double-checked what I was doing against the Debian SSD Optimization guide and everything seemed right.
At this point I rebooted and things went wrong. The system refused to mount the volume as anything but read-only complaining about the "discard" flag not being recognized.
I've tried booting from several different live CDs (well, over PXE anyway) but they all refuse to mount the volume for one reason or another (after running through modprobe dm-mod; cryptsetup luksOpen et al) and I suspect it's the wrong way to go.
Well, the problem I'd rather solve is to figure out a way to make the crippled system (which boots with the root partition mounted read-only) mount the root partition rw by somehow ignoring the discardflag in /etc/fstab, /etc/lvm/lvm.conf and /etc/crypttab so that I can change those back, reboot and have things back the way they were.
Edit: It just dawned on me why it didn't work, the filesystem for the root partition is ext3 for some reason. I had naively assumed it would be ext4. So the solution is clearly to somehow mount while ignoring the discard flag.
|
Get to a shell ( boot into rescue / single user mode if needed ) and just mount -o remount,rw /.
Or if you are booting from a rescue cd, then it knows nothing about /etc/fstab, so just don't specify the -o discard when mounting.
| Followed SSD-optimization advice, now root partition won't mount rw |
1,522,347,185,000 |
I would like to understand more about the Linux boot process and how encryption works for the boot partition. I have a few questions.
I know that a UEFI system must have a ESP partition, which can be mounted either in /boot/efi or /efi. The ESP partition contains the bootloader and the kernel. On my Endeavour OS system I also have /boot, which only contains the Intel microcode. What I understood is that the system first loads the bootloader (in my case systemd-boot) which then loads the selected kernel. So, with my current configuration and in general in UEFI system, what is the purpose of /boot if a separate /efi exists?
Then, I would like to encrypt my system and I was reading the Arch Wiki guide "Encrypted boot partition (GRUB)". In this case, what is left unencrypted is GRUB and the ESP. For a UEFI system, what is the advantage of this approach? What is now encrypted that would be so in a "normal" configuration? What is still inside the ESP?
I am also trying to learn what is EFISTUB and how it works. What I have understood is that a bootloader is not used and unified kernel images are put inside the ESP. In this case is /boot still necessary?
|
When you have an UEFI system, its firmware will expect to find at least the first part of whatever you want booted in ESP. That first part could be the UEFI version of GRUB, some other bootloader like systemd-boot, or a unified kernel image with EFISTUB.
(If you use Secure Boot, and the firmware won't let you change the built-in Secure Boot keys, you'll have to use a Secure Boot shim (shimx64.efi) as the first step, before whatever else you wish to use. If you can configure the firmware to use your own Secure Boot keys and you sign the bootloader & the kernel yourself with your own keys, you won't need the shim.)
Unless you have some very special UEFI firmware, the ESP can never be encrypted, or else the firmware cannot make any sense of it. But with Secure Boot, any executable code in ESP must be signed, so any significant tampering of the ESP will stop the system from booting (assuming the implementation is correct).
Where the kernel needs to be depends on what you use as a bootloader. If you use GRUB, the kernel can be on any filesystem GRUB can understand (LVM or classic partition; encrypted or not). With systemd-boot, I understand the kernel needs to be on the ESP; and with EFISTUB, the firmware is told to read an appropriately prepared kernel file directly, so it obviously needs to be on the ESP.
GRUB can do some forms of disk encryption, but it might not have support for the newest disk encryption algorithms yet. Also, if you want to use a security device like a smart card or a Yubikey as a disk encryption key, then you'll probably need an initramfs file that will contain the necessary infrastructure for accessing that security device and presenting any necessary prompts to the user. Normally an initramfs file goes to the same place the kernel goes to.
If you place your kernel (and initramfs if needed) to the ESP, you probably won't need a separate /boot at all (or your ESP can be mounted at /boot, as commented by @muru). The same is true if you use GRUB and it can directly read your kernel (and initramfs if needed) from your root filesystem, i.e. if want encryption and are satisfied with the encryption options provided by GRUB.
But the "absolute maximum security at the price of some convenience" option could be something like:
the ESP contains only the Secure Boot shim (if needed) and GRUB, both protected by Secure Boot signatures
GRUB will prompt a passphrase to unlock an encrypted /boot, and will read the kernel & initramfs from there (encrypted, but maybe not quite the best possible encryption)
initramfs contains the infrastructure to request a smart card/Yubikey/etc. which will contain the key(s) for unlocking any other filesystems. These can now use the hardware security device and/or the latest & greatest encryption algorithms supported by the kernel. If the system contains a TPM chip, you could even use its PCR registers to verify that the firmware or any of the previous components of the boot process haven't been tampered with.
| Encrypted boot partition: advantage of encrypted boot partition |
1,522,347,185,000 |
I have get informed on how prepare a LUKS system & partitions, giving a key/passphrase, etc. But for a new fresh install of linux.
How to encrypt an already installed/configured linux system ?
EDIT I have made my linux system as a server. I need it crypted, and I would like to test encryption without to reinstall anything.
|
Make another partition (or image file) with an encrypted fs for your data. Moving root on the fly to an encrypted fs on the same disk does not work.
| Encrypt existing disk with LUKS? |
1,522,347,185,000 |
When encrypting a file with symmetric key, most common utilities (such as gpg, mcrypt, etc) store information in the encrypted message which can be used to verify integrity of the key during decryption. E.g., if the wrong key is entered during decryption, gpg will retort with:
gpg: decryption failed: bad key
Suppose I am encrypting a file containing a string which is random. Then the key integrity check used in the standard utilities adds a vulnerability.
Is there a common utility which will not store any information or redundancy for verifying key/message integrity (and so will "decrypt" an encrypted file for any supplied key)?
|
As an alternative to my other answer, I'd like to offer something else. Something beautiful ... dm-crypt.
Plain dm-crypt (without LUKS) doesn't store anything about the key; on the contrary, cryptsetup is perfectly happy to open a plain device with any password and start using it. Allow me to illustrate:
[root:tmp]# fallocate -l 16M cryptfile
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pa55w0rd"
Note: Your cryptfile has to be greater or equal than 512 bytes. I assume due to the minimum sector size cryptsetup enforces.
At this point, you would want to write all your random data out to the /dev/mapper/cfile-open. It would seem prudent to me that you size the original cryptfile appropriately ahead of time so that you will use all the space; however, you could just as easily treat this as another added bit of security-through-obscurity and make a note of exactly how much data you wrote. (This would only really work if the underlying blocks were already semi-random, i.e., if you're not going to completely fill the file, you should create it with openssl rand or dd if=/dev/urandom instead of fallocate.) ... You could even use dd to start writing somewhere in the middle of the device.
For now, I'll do something simpler.
[root:tmp]# cryptsetup status cfile-open
/dev/mapper/cfile-open is active.
type: PLAIN
cipher: aes-cbc-essiv:sha256
keysize: 256 bits
device: /dev/loop0
loop: /tmp/cryptfile
offset: 0 sectors
size: 32768 sectors
mode: read/write
[root:tmp]# b $((32768*512))
B KiB MiB GiB TiB PiB EiB
16777216 16384.0 16.00 .01 0 0 0
[root:tmp]# ll cryptfile
-rw-r--r--. 1 root root 16777216 Feb 21 00:28 cryptfile
[root:tmp]# openssl rand -out /dev/mapper/cfile-open $((32768*512))
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 00 1d 2d 11 ac 38 c4 d3 cc 81 4f 32 de 64 01 ca |..-..8....O2.d..|
00000010
[root:tmp]# cryptsetup close cfile-open
At this point I've filled my encrypted file with 16 MiB of random data. Watch what happens when I open it again using the wrong passphrase and then just to be clear, I'll open it again with the correct one and you'll see the original data is still intact.
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pass"
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 89 97 91 26 b5 46 87 0c 67 87 d8 4a cf 78 e6 d8 |...&.F..g..J.x..|
00000010
[root:tmp]# cryptsetup close cfile-open
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pa55w0rd"
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 00 1d 2d 11 ac 38 c4 d3 cc 81 4f 32 de 64 01 ca |..-..8....O2.d..|
00000010
[root:tmp]#
Enjoy.
| File encryption utility without key integrity check (symmetric key) |
1,522,347,185,000 |
I need to enlarge my / (root) partition, I have a lot of space on my /home partition so how can I do this? The drive is encrypted with LUKS.
My system is Fedora 20.
I have another thread here which mentions system-config-lvm but this seems to be a outdated tool as it is not installed or in the repositories.
Gparted doesn't work as it doesn't support LUKS encryption.
Here is:
~]$ sudo fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
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: 7AE6E531-9898-4C7C-8C35-41B4FDB9374A
Device Start End Size Type
/dev/sda1 2048 411647 200M EFI System
/dev/sda2 411648 1435647 500M Microsoft basic data
/dev/sda3 1435648 976773119 465.1G Microsoft basic data
Disk /dev/mapper/luks-e69b0b4c-a8e0-425f-988d-8c635729503b: 465.1 GiB, 499370688512 bytes, 975333376 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/fedora_hostname-swap: 3.8 GiB, 4043309056 bytes, 7897088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/fedora_hostname-root: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/luks-b7af1bce-82c4-4921-aac1-bce701e30256: 50 GiB, 53684994048 bytes, 104853504 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/fedora_hostname-home: 411.3 GiB, 441639239680 bytes, 862576640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Here is:
~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-3 50G 45G 2.0G 96% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 80K 1.9G 1% /dev/shm
tmpfs 1.9G 9.0M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs 1.9G 20K 1.9G 1% /tmp
/dev/sda2 477M 131M 317M 30% /boot
/dev/sda1 200M 9.6M 191M 5% /boot/efi
/dev/mapper/fedora_hostname-home 405G 202G 183G 53% /home
Here is:
]$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/fedora_hostname/swap
LV Name swap
VG Name fedora_hostname
LV UUID qQQRVR-toXX-J0M7-lTH5-d8Lr-AUq3-EHJ6A4
LV Write Access read/write
LV Creation host, time hostname.lan, 2014-03-24 15:51:10 +0000
LV Status available
# open 2
LV Size 3.77 GiB
Current LE 964
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/fedora_hostname/home
LV Name home
VG Name fedora_hostname
LV UUID In2lRz-16ul-VhH5-SQOE-yqlt-tMB3-5JM7ea
LV Write Access read/write
LV Creation host, time hostname.lan, 2014-03-24 15:51:10 +0000
LV Status available
# open 1
LV Size 411.31 GiB
Current LE 105295
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4
--- Logical volume ---
LV Path /dev/fedora_hostname/root
LV Name root
VG Name fedora_hostname
LV UUID bBWzcC-nhhd-s8km-MMGi-uGQ0-8yBv-HClQgp
LV Write Access read/write
LV Creation host, time hostname.lan, 2014-03-24 15:51:16 +0000
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
|
The answer is in this thread....
Exerpt:
Therefore, the steps would be like this:
Shrink the /home "filesystem". (e.g. if it is ext4, it should be
resized using resize2fs).
Shrink the /home LVM partition (/dev/mapper/fedora_hostname-home)
size so that it completely includes /home shrinked filesystem using
lvreduce
If the shrinked filesystem is smaller than /home LVM partition, you
can resize the filesystem again to fill LVM logical volume
completely. I usually use this method so that I don't need to
calculate sizes accurately! :P
(After each of the above steps, you can mount /home to see if it mounts correctly, and data is there. If not (for example because of wrong parameters), you can revert that problematic step).
The steps for enlarging / partition would be like this:
Enlarge / LVM partition (/dev/mapper/fedora_hostname-root) to fill the free space (using lvextend)
Enlarge / LUKS partition to fill /dev/mapper/fedora_hostname-root
LVM partition (using cryptsetup resize)
Enlarge / filesystem to fill / LUKS partition (e.g. using resize2fs
if ext2/3/4)
| How can I resize my encrypted root and home partitions, to give root more space? |
1,522,347,185,000 |
Does anyone know of a good Howto on how to fully encrypt a HDD (even the /boot!) with GRUB2?
Is it possible using fedora 14 or ubuntu 10.04?
|
Here is the link:
http://xercestech.com/full-system-encryption-for-linux.geek
| Full disc encryption with GRUB2 |
1,522,347,185,000 |
How does Grub's MD5 algorithm work? When you run grub-md5-crypt and enter the same password each time you get different results. Generally md5 is supposed to always return the same hash, so why does grub's version return something different each time?
Also, considering that, how is it then determining you are entering the correct password? If you each encryption creation with the same password generates a different hash, then how is it that later on when you enter your password (and theoretically the same algorithm is used) that since the hash's will be different, how are they matched to show you provided the correct password?
I'm assuming a salt is used somewhere and that the salt is randomly generated, but what is the salt, and how is it generated exactly, and then how is it replicated?
|
The grub source code is the best place to find out. The necessary logic is in stage2/md5.c in:
int md5_password (const char *key, char *crypted, int check)
It produces strings of the form: $1$aaaaaaaa$bbbbbbbbbbbbbbbbbbbbbb where the "aaaaaaaa" sequence is a random salt, and "bbbbbbbbbbbbbbbbbbbbbb" is the result of the mixing of the password and the salt up 1000 times in a particular way, and taking a modified base64-encoding of the md5 result.
The modified-base64 dictionary is:
./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
The actual mixing algorithm can be redistributed under the terms of the GNU General Public License version 2 (or any later version), and you can get it from the GNU FTP site or any GNU mirror.
| Grub MD5 Crypt algorithm |
1,522,347,185,000 |
Simple question.
With rar
rar X file.tar -p"mypass"
With 7z
7z X file.7z -p"mypass"
Vim can encrypt file using :X
and every time you want to open file
must use the password.
The question is: is possible to pass the pass as argument like rar and 7z?
A thing like this
vim filex.enc.txt -P"mypass"
|
With --cmd you can give Vim a command to run before reading the file on the command line (as if it was part of your ~/.vimrc file). By setting the key option to the value of the encryption key in this way, you may give the encryption key on the command line:
$ vim --cmd "set key=mysecretkey" myencryptedfile
| vim: is possible to open a encrypted file using cli? |
1,522,347,185,000 |
I've followed this guideline to the point where I encrypt the target partition:
cryptsetup -h sha256 -c aes-xts-plain64 -s 512 luksFormat /dev/nvme0n1p3
Then, the error appears, even though I'd unmounted the home partition previously like so:
umount -l /home
The reason for the -l-flag was that it didn't work without it. Moreover, in order to get so far, I had to boot my system till reaching the user-login screen, then press CTRL+ALT+F2 to get into tty2, there log into my user via "login" and "password", then unmount the "/home" - partition forcefully.
Even though I'd checked previously via gparted which is the mount-point on the hard-drive related to /home, it states
"Device /dev/nvme0n1p3 is in use. Can not proceed with format
operation."
albeit having unmounted "/home" previously.
How can I finish encrypting my "/home" - partition with LUKS (cryptsetup)? Could I use this in the same way to encrypt my swap, /temp, and /var/temp as well, since I couldn't encrypt the entire ubuntu 20.04 installation due to being installed in parallel to Windows 10?
|
umount -l is so called lazy unmount -- for busy filesystems this waits until the filesystem is no longer in use before really unmounting it.
From mount manpage:
-l, --lazy
Lazy unmount. Detach the filesystem from the file hierarchy now, and clean up all references to this filesystem as soon
as it is not busy anymore.
So the cryptsetup call failed because your /home is still in use and it is used because you are logged in. You need to logout first and then unmount your /home. For that you'll need to either login as root (which doesn't use /home) or use LiveCD.
Yes you can use the same steps to encrypt your swap (this can be done from running system after swapoff -a to disable swap) and other partitions.
Btw. if you want to encrypt your entire system, I'd recommend using LVM which allows you to setup the encryption on a single point on the physical volume layer (but that would require reinstalling your system).
| cryptsetup luksFormat error "Device /dev/nvme0n1p3 is in use. Can not proceed with format operation." |
1,522,347,185,000 |
I am trying to download an update for a piece of software, and my package manager says that the key is invalid and thus warns me.
W: Failed to fetch https://deb.torproject.org/torproject.org/dists/buster/InRelease The following signatures were invalid: EXPKEYSIG 74A941BA219EC810 deb.torproject.org archive signing key
Then the output after listing the key in GPG.
pub rsa2048/0xEE8CBC9E886DDD89 2009-09-04 [SC] [expires: 2022-08-05]
Key fingerprint = A3C4 F0F9 79CA A22C DBA8 F512 EE8C BC9E 886D DD89
uid [ unknown] deb.torproject.org archive signing key
sub rsa2048/0x74A941BA219EC810 2009-09-04 [S] [expires: 2020-11-23]
Key fingerprint = 2265 EB4C B2BF 88D9 00AE 8D1B 74A9 41BA 219E C810
As you can see, the subkey has expired recent to writing this post.
I went to the developer's website and the signing key is unchanged. How do I continue the software update without skipping the signing process?
|
From 2019.www.torproject.org/docs/debian.html.en, you can run these commands to add the key to the trusted apt keys, I only added sudo:
curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
After that sudo apt-key list (or gpg --list-keys) should list the updated key:
pub rsa2048 2009-09-04 [SC] [expires: 2024-11-17]
A3C4 F0F9 79CA A22C DBA8 F512 EE8C BC9E 886D DD89
uid [ unknown] deb.torproject.org archive signing key
sub rsa2048 2009-09-04 [S] [expires: 2022-06-11]
Now you can install the keyring package if you wish to keep the key current:
sudo apt update
sudo apt install deb.torproject.org-keyring
The deb.torproject.org-keyring package contains the current version of the archive signing key (/etc/apt/trusted.gpg.d/deb.torproject.org-keyring.gpg) to validate the authenticity of tor packages.
If you install the package, you'll automatically update the key next time you run sudo apt update; sudo apt upgrade whenever there is an updated version of the key available (assuming the currently installed key is not expired to fetch the package via apt).
| Author's GPG subkey has expired, what can I do? |
1,522,347,185,000 |
To encrypt a file using a person's public key, I can use the following command.
gpg --recipient [email protected] --encrypt --armor file_name
I don't quite understand when this command has multiple --recipient parameters. Below is an example.
gpg --recipient [email protected] --recipient [email protected] --encrypt --armor file_name
This command only generates a single encrypted file called file_name.asc. In this case, does it mean file_name.asc can be decrypted by both user's corresponding private key? Could anyone help to explain when we need multiple --recipient parameters?
|
In this case, does it mean file_name.asc can be decrypted by both user's corresponding private key?
Yes, any of the recipient keys will be able to decrypt the message. Strictly speaking, the message is encrypted using a common key, and that key is encrypted using each provided public key. Thus any of the corresponding private keys can decrypt the common key and then the message.
Could anyone help to explain when we need multiple --recipient parameters?
A common scenario is for email encrypted to multiple recipients. Another is storing encrypted content accessible to multiple users without any shared key.
| What does it mean by gpg encrypting a file with multiple recipients? |
1,522,347,185,000 |
I have this file I use to set my username and password before exporting the value.
#!/bin/bash
echo -n "User:";
read user
echo -n "Password:";
read -s password
export http_proxy=http://$user:$password@$domain:$portnum
if curl -silent http://www.google.com | grep authentication_failed;
then
echo NO CONNECT
unset http_proxy
else
echo OK
fi
in history, printenv, and export -p I'm able to see the value that I have set
furthermore, I'd like an encrypted form of my password inside $password, versus that value containing my password verbatim.
I'm familiar with using openssh to salt passwords, or printing hash using perl's crypt(), but for my purpose, I cannot see it's usage? any tips will be appreciated?
|
I am unable to reproduce the issue you mentioned with password showing up in the output from the history command.
The password showing up in the output from printenv and export -p is working as intended. Those commands display the environment variables, and that's where you put the http_proxy string.
The environment variables are automatically inherited by child processes, but not by any other processes. I don't see why you think that is a major concern, as it is only visible to processes within the same security domain.
But you could stop putting it in an environment variable and instead use normal shell variables. Then it would not be inherited by child processes. Since you probably want curl to have access to the environment variable, then you could pass the environment variable to just that one command and not all the other commands.
#!/bin/bash
echo -n "User:";
read user
echo -n "Password:";
read -s password
proxy="http://$user:$password@$domain:$portnum"
if http_proxy="$proxy" curl -silent http://www.google.com | grep authentication_failed;
then
echo NO CONNECT
else
echo OK
fi
| What are ways to encrypt a password inside an environment variable |
1,522,347,185,000 |
I have some RNA-seq files need to be decrypted.
For example
1672_WTSI-OESO_005_w3.tar.gz.gpg
Likely I have key for that in same folder
1672_WTSI-OESO_005_w3.gpgkey
I have also have a file name
1672_WTSI-OESO_005_w3.md5
Inside that I have
884f9fa72fb7f6adbba95dc677eb0ec9 1672_WTSI-OESO_005_w3.tar.gz.gpg
EDITED
[fi1d18@cyan01 fereshteh]$ gpg --decrypt --passphrase-file=1672_WTSI-OESO_036_a_RNA.gpgkey --output - 1672_WTSI-OESO_036_a_RNA.tar.gz.gpg | tar -xvzf -
gpg: CAST5 encrypted data
can't connect to `/home/fi1d18/.gnupg/S.gpg-agent': No such file or directory
gpg: encrypted with 1 passphrase
1672_WTSI-OESO_036_a_RNA/
1672_WTSI-OESO_036_a_RNA/mapped_sample/
1672_WTSI-OESO_036_a_RNA/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-OESO_036_a_RNA.dupmarked.bam.bai
1672_WTSI-OESO_036_a_RNA/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-OESO_036_a_RNA.dupmarked.bam
gpg: WARNING: message was not integrity protected
gzip: stdin: invalid compressed data--crc error
gzip: stdin: invalid compressed data--length error
tar: Skipping to next header
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[fi1d18@cyan01 fereshteh]$
|
The file is, according to the GnuPG output that you show, a file encrypted using the CAST5 algorithm. This is a symmetric encryption algorithm, meaning that you should just be able to use the passphrase in that .gpgkey file with gpg --decrypt to decrypt it (without importing it into your keyring; it's not that kind of key).
To decrypt the file and pass the decrypted data directly to tar for unpacking, you could use
gpg --decrypt --passphrase-file=1672_WTSI-OESO_005_w3.gpgkey --output - 1672_WTSI-OESO_005_w3.tar.gz.gpg |
tar -xvzf -
This would read the key from the provided file, decrypt the message using that key, and pass the data on to tar.
If the file 1672_WTSI-OESO_005_w3.gpgkey does not decrypt the message, then you will have to get in touch with whoever provided you with the encrypted file and ask them for instructions about how to decrypt it.
The .md5 file is used to ensure that the .gpg file contains the correct data. You can use it to verify the data like this:
md5sum -c 1672_WTSI-OESO_005_w3.md5
If this does not give the output
1672_WTSI-OESO_005_w3.tar.gz.gpg: OK
then the file is corrupt somehow, and you need a fresh copy of it from wherever you got it. If it says FAILED, then gpg and tar will not be able to decrypt and unpack the data.
The error shown at the end of the updated question (now deleted) is Cannot write: Disk quota exceeded. This means that the files extracted from the archive are too big to fit in the space allotted to your account.
To fix this, either delete or compress files no longer needed, until you have enough space to extract the archive, or talk with your system administrator(s) and have them allocate more disk space to your account.
| Decrypting GnuPG-encrypted files |
1,522,347,185,000 |
This is more of a educational and curiosity question, rather than tying to fix a problem. I have an Ubuntu system using LUKS. lsblk shows this:
Noteably, / is encrypted but /boot and /boot/efi are not. This is important because LUKS needs /boot to be unencrypted in order to boot GRUB.
But... / contains /boot. So it seems that if / is encrypted, that would force /boot to be too. After all, how would you know where on disk /boot starts, since /'s pointer to /boot is encrypted? (i assume)
Thank you!
|
The devices (partitions) that / and /boot reside on are different,
and one can be encrypted while the other is not.
GRUB knows how to find /boot by using something like set root=(hd0,1) or search --hint=... as defined in grub.cfg.
Since GRUB can handle booting into multiple OS's installed simultaneously, the / file system (or C:)
cannot be used to locate /boot unambiguously.
| LUKS - How can / be encrypted but /boot and /boot/efi are not? |
1,522,347,185,000 |
Let's assume I lost a LUKS encrypted USB pen drive. I think the file system type (ext4/fat32/...) doesn't play a role. A foreign person finds it. Of course he cannot access my data because he doesn't have the password. But he can change a single byte in the middle of the "raw" data so the data is damaged.
After the pen drive is returned to me, is it possible to verify my data was damaged or not?
I thought reading the whole mapper device will cause an I/O error but unfortunately it does not. I also checked dmesg.
# create an all zero 100MiB file
dd if=/dev/zero of=moh bs=100M count=1
# format it as LUKS device
/usr/sbin/cryptsetup luksFormat moh
# map it to /dev/mapper/moh
sudo cryptsetup luksOpen moh moh
# initialize mapper file to zero
sudo dd if=/dev/zero of=/dev/mapper/moh
# close LUKS device
sudo cryptsetup luksClose moh
# overwrite 1MiB with zeroes at offset 10MiB. After this the LUKS device is damaged.
sudo dd if=/dev/zero of=moh conv=notrunc bs=1M seek=10 count=1
# open LUKS device and see if it complains
sudo cryptsetup luksOpen moh moh
# read all data to see if it complains
sudo dd if=/dev/mapper/moh of=/dev/null
The above commands proofs that opening and reading a damaged LUKS device does not produce any error.
Please note that I don't want to perform any file system checks. Instead I want to verify whether the LUKS device is untouched on the encryption level.
Because I am looking for a single command to verify a luks device I hope you understand this is not a programming question more suitable for SO.
|
It is possible but not with "plain" LUKS, you need to set up authenticated encryption. This is possible with LUKS v2, you need to create the LUKS device using the --integrity option with luksFormat. This will basically add checksums for the encrypted data to ensure integrity, without it LUKS/dm-crypt simply doesn't care (or know) what is on the disk and if you overwrite it with zeroes it will "decrypt" those zeroes. See the Authenticated disk encryption section in cryptsetup man page for more details.
| Is it possible to check if a LUKS device has been damaged by a foreign person? |
1,522,347,185,000 |
I have /etc/crypttab as follows:
sda7_crypt UUID=<...> /dev/sda8:/keyfile luks,discard,keyscript=/lib/esi/tpm_key_pass
sda7_crypt is my root filesystem, so I use update-initramfs to decrypt it from early on (otherwise I could not continue boot).
Yet systemd automatically creates a systemd-cryptsetup@sda7_crypt.service unit, which depends upon a dev-sda8:-keyfile.device, which times out. This eventually fails, but it slows boot time down and creates error messages.
How do I indicate that this is already mounted by initram, and does not need to be mounted by systemd? I had thought about option noauto in crypttab, but was concerned it might prevent it from loading in ini tram?
UPDATE:
I tried noauto, it didn't work. Still mounts in initram, but also still tries on boot. crypttab now looks like:
sda7_crypt UUID=<...> /dev/sda8:/keyfile luks,discard,keyscript=/lib/esi/tpm_key_pass,noauto
What can I do to clean this up?
|
Turns out this is 2 individual systemd issues, specifically how systemd-cryptsetup-generator works.
It doesn't recognize keyscript=... option, so it chokes on keys that are valid for passdev like /dev/sda8:/keyfile.
The systemd units automatically generated by systemd-cryptsetup-generator are not smart enough to recognize that the item already is mounted, and so tries to mount it again.
For more details, see this Debian bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618862
According to the bug report, you can stop it from generating the systemd units by passing kernel options luks=no, but that prevents all crypttab automatic mounting. This is fine if all you have is encrypted root, but if there are separate individual partitions, then they don't mount.
| why does systemd cryptsetup try to remount the root partition already mounted? |
1,522,347,185,000 |
Is it possible to set up a bootloader that automatically begins shredding the header.img file and then the encrypted partition itself upon X failed attempts at decrypting the partition?
If this does not already exist - is it possible to create any such software without extensive work?
Cheers,
|
Yes (for your own bootloader / initramfs) and No (for a thief who tries to decrypt it from a Live CD and thus circumvents your trap). So the question is, which situation are you trying to cover here...
From a security standpoint it's not a good idea since it doesn't work and the password should be impossible to bruteforce anyhow. Also there is a high risk of triggering that trap yourself.
It's entirely possible to make mistakes when entering a passphrase. My favourite is the caps lock key, hit it accidentally and not notice (since the password is not echoed) and... in your case it goes boom.
In order to implement it you'd have to see if your distro's flavour of initramfs has a hook system or similar. A normal cryptsetup call may look like this:
cryptsetup -T 5 luksOpen /dev/sda1 luksroot
To boobytrap it you could simply do something like:
cryptsetup -T 5 luksOpen /dev/sda1 luksroot || boobytrap
And boobytrap would be a function that deletes your stuff while keeping the thief occupied. In addition to that you must absolutely check the error code of cryptsetup; so you don't delete because of wrong parameters or anything like that. Check the RETURN CODES section in the manpage.
Pseudocode: (untested and not recommended)
boobytrap() {
if [ $? -eq 2 ]
then
# kill the disk silently in the background...
dd bs=1M if=/dev/zero of=/dev/sda1 seek=2 2> /dev/null &
# ...while keeping the thief busy entering more passwords
cryptsetup -T 9999 luksOpen /dev/sda1 luksroot \
&& echo Congrats, but I already deleted your data...
fi
}
I hope you have a good backup.
| Automatically shred LUKS partition upon X failed decryption attempts? |
1,522,347,185,000 |
I created 2 test folders:
mkdir /home/oshiro/Desktop/encrypted
mkdir /home/oshiro/Desktop/decrypted
oshiro@debian:~/Desktop$ ls -l
total 8
drwxr-xr-x 2 oshiro oshiro 4096 Feb 15 20:34 decrypted
drwxr-xr-x 2 oshiro oshiro 4096 Feb 15 20:33 encrypted
I installed encfs:
sudo aptitude install encfs
I then tried using encfs with the 2 folders I created above:
oshiro@debian:~/Desktop$ encfs /home/oshiro/Desktop/encrypted /home/oshiro/Desktop/decrypted
Creating new encrypted volume.
Please choose from one of the following options:
enter "x" for expert configuration mode,
enter "p" for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?> p
Paranoia configuration selected.
Configuration finished. The filesystem to be created has
the following properties:
Filesystem cypher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 3:0:1
Key Size: 256 bits
Block Size: 1024 bytes, including 8 byte MAC header
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File data IV is chained to filename IV.
File holes passed through to ciphertext.
New Encfs Password:
Verify Encfs Password:
But then I got this error:
fuse: failed to open /dev/fuse: Permission denied
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
oshiro@debian:~/Desktop$
I've configured encfs on Ubuntu 12.04 without any issues, I had an issue on CentOS 6.5 which I corrected by running:
sudo chmod +x /usr/bin/fusermount
but that was for a slightly different error message. I tried the same command on Debian 7.4, but it made no difference. Anyone know how to get this to work?
|
Solution:
usermod -aG fuse <your-username>
reboot
| Difficulty with EncFS on Debian |
1,522,347,185,000 |
I'm trying to figure out encfs, but am having some difficulty.
This is what I have done so far:
I created 2 test folders
mkdir /home/oshiro/Desktop/encrypted
mkdir /home/oshiro/Desktop/decrypted
The difficulty is that the next command gives me a permission denied message:
encfs /home/oshiro/Desktop/encrypted /home/oshiro/Desktop/decrypted
When I run that command in Ubuntu 12.04, it works perfectly and both folders work correctly, i.e. I can create files folders in the decrypted folder, and they appear in the encrypted folder automatically etc.
However, when I try to run that command in CentOS 6.5, I get a permission denied error. When I add sudo infront of that command, it mounts the decrypted folder as normal, but I can't open the folder as a normal user, I get a permission denied error.
On Ubuntu 12.04, I don't need to use sudo to run encfs. How do I run that command without sudo on CentOS 6.5, or is that unsafe? If it's unsafe, how to I mount that folder so I can access that folder by the user logged in?
Here is the full error I get when I try to run encfs on CentOS 6.5 without sudo:
[oshiro@centos- ~]$ encfs /home/oshiro/Desktop/encrypted /home/oshiro/Desktop/decrypted
EncFS Password:
fuse: failed to exec fusermount: Permission denied
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
[oshiro@centos ~]$
|
I fixed the problem by running the following command before mounting:
sudo chmod +x /usr/bin/fusermount
| Difficulty with EncFS on CentOS |
1,522,347,185,000 |
I have my hard disk encrypted with LUKS, but I make regular backups to an unencrypted external harddrive. Is there any reason I shouldn't setup LUKS on my backup drive as well?
Obviously, the big thing will be keeping track of the key/passphrase, but I believe I have that in hand. I'm more concerned about obsolescence of LUKS, I guess. I want to make sure that if my backup sits around for five or ten years, I'll still be able to mount and access it on whatever linux system I have setup at the time.
|
I'm more concerned about obsolescence of LUKS
What about USB mass storage support? The underlying PATA or SATA disk access? (It's already pretty hard to find motherboards with PATA ports.) How about Linux itself, or USB for that matter?
As frostschutz said, it depends very much on why you are encrypting the main drive.
If your main concern is LUKS obsolescence, there's a pretty simple solution. Make a small unencrypted partition with some basic file system support for which is unlikely to go away (ext2, ext3 or maybe even FAT32) and put ISOs (live and install) for your favorite Linux distribution there, and devote the majority of the disk to an encrypted partition holding the actual backup. Store hashes of the ISOs to be able to detect corruption, and check them on a regular schedule to make sure the drive does not suffer from bit rot. If you need to, just boot from the ISO and mount the encrypted partition. This is trivially accomplished in a virtual machine. Be sure to try it out before you need it; backups are easy, restores are hard.
And major Linux distribution ISOs don't go away easily. Here is year 2000 vintage Red Hat Linux 6.2, which came with a 2.2.14 kernel. I'm sure you can find older if you look around a little.
| Any reason not to use LUKS on a backup drive? |
1,479,187,367,000 |
How to encrypt a file using the command below, if the recipient mail is not showing up when I type the --list-keys command.
Sample Encrypt file command using GPG
gpg --output "output_filename" --encrypt --recipient [email protected] "input_filename"
Output for gpg --list-keys shows to imported public keys one is User_A which shows an email. However another one Company ABC doesn't show an email. Which command can I use to encrypt the file and send it to Company ABC where they can decrypt it using their private key?
pub 2048R/4XXXX4E4 2016-08-29
uid [ultimate] User_A <[email protected]>
sub 2048R/DXXXX7E 2016-08-29
pub 1024D/FXXXXX3D 2007-01-20
uid [ unknown] Company ABC
sub 2048g/7XXXXXE 2007-01-20
|
You can use the identifier instead of an email address:
gpg --output "output_filename" --encrypt --recipient FXXXXX3D "input_filename"
(You should really specify the full fingerprint but that's another story.)
| How to encrypt if public key does not have email |
1,479,187,367,000 |
When I try to LUKS encrypt a partition on a CentOS 7 server using the command cryptsetup -y luksFormat /dev/sda4, the attempt fails with the error Cannot format device /dev/sda4 which is still in use. How can I resolve this error and successfully LUKS encrypt the partition?
Here is the terminal record:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-1 50G 1.1G 46G 3% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 3.8G 8.7M 3.8G 1% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/sda6 296G 65M 281G 1% /vpn
/dev/sda2 477M 110M 338M 25% /boot
/dev/sda1 200M 9.8M 191M 5% /boot/efi
/dev/sda3 596G 73M 565G 1% /home
/dev/sda7 296G 65M 281G 1% /test
/dev/sda5 296G 65M 281G 1% /public
/dev/sda4 296G 65M 281G 1% /data
[root@localhost ~]# cryptsetup -y luksFormat /dev/sda4
WARNING!
========
This will overwrite data on /dev/sda4 irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase:
Verify passphrase:
Cannot format device /dev/sda4 which is still in use.
|
Is the goal to completely destroy everything on your current /data disk and create a new, entirely empty encrypted volume? Because that's what you're doing with this command. That's what the whole "WARNING: This will overwrite data on /dev/sda4 irrevocably" thing is about. You will lose all the current data, and start over with an empty block device.
More likely, what you want to do is take a data backup of /data, create the new volume, then restore the backup into the new, encrypted filesystem. You can use tar for this nicely:
cd /data
tar czvf /root/data_backup.tar.gz .
Then, and only then, do you write over the filesystem using cryptsetup. The way to get around your error is by unmounting first:
umount /data
cryptsetup -y luksFormat /dev/sda4
Then you can luksOpen the new /dev/sda4, then mkfs onto the encrypted mapping, mount the result, and finally cd into it and restore the existing data with tar.
If you are actually, 100% sure that you want to irrevocably destroy everything in the current /data, then skip the first step, and just jump down to umount /data.
Edit: If you're doing this at all it's possible that the current data is sensitive. If so, consider:
cryptsetup luksFormat does not overwrite all existing data. It only overwrites the first few KiB. If the data is sensitive you will first want to overwrite all data on the partition, e.g. with wipe, see https://superuser.com/questions/831486/complete-wiping-of-hard-drive-shred-wipe-or-dd. If the partition is large and if there is not much data on the other partitions it will be faster to include all data in a backup on external storage, use the internal disk's "secure erase" feature to blank it in an instant, prepare /data with LUKS and restore your backup.
To not contaminate /root with the sensitive data, write to a sufficiently large tmpfs, a smaller volume which you can secure-erase afterward or a new filesystem in an encrypted container, or pipe the tar output through gpg before writing the backup.
cryptsetup-reencrypt can encrypt the data in-place. As the tool is not crash resistant, having a backup is still advisable.
An existing backup becomes the primary copy during the operation. For important data, a second backup should be made so that more than one copy exists at all times.
| Cannot format device /dev/sda4 which is still in use |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.