Score:2

Secure/password protected access to a file in Ubuntu 22.04

jm flag

I have just recently installed Ubuntu 22.04 on my computer, and I don't know much about Linux. I have a file that I'm trying to secure (only accessible by password, for example)

Does anybody know how can I do that?

FedKad avatar
cn flag
See also this answer: https://askubuntu.com/a/1281622/855322
Score:5
ma flag

You can do that by:

1- Using GnuPG

  • Open the terminal.
  • Use the cd command and ls command to navigate to the directory containing the file you want to password-protect.
  • Once inside the directory, run the following command to encrypt your file:
gpg -c filename
  • Finally, when prompted for a passphrase, type in one that's strong and easy to remember.

GnuPG will now create an encrypted file (with .gpg extension) in your current working directory. To access it, you'll need to decrypt it. For this, run the following command, and when prompted for a password, enter the one you used to encrypt the file and hit Enter:

gpg filename.gpg

GnuPG will return a decrypted version of the file in your current working directory.

2- Using zip

  • Open the terminal and use the cd and ls commands to go into the directory with the files to encrypt.
  • Enter the command in the following format to create a password-protected zip file:
zip --password preferred_password archive_file.zip filename1 filename2

Here, replace preferred_password with the password you want to use to encrypt the archive and archive_file.zip with the file name you want to give to the resultant archive.

Now, when you want to access these files, unzip the archive and enter your password. Or, to do it via the terminal, run:

unzip archive_file.zip

Zip will now ask you for a password. Enter the password you set at the time of encryption and hit Enter to decrypt the file.

3- Using mcrypt

  • Open the terminal, and using cd and ls, go into the directory that contains the file you want to encrypt.
  • Enter the command below to list out all the supported encryption algorithms:
mcrypt --list
  • Finally, encrypt your file using:
mcrypt -a algorithm_name filename
  • When asked for a passphrase, enter it twice and hit Enter. mcrypt will now encrypt your file and save it with the ".nc" extension. If you wish to open this file, you'll need to decrypt it. To do this, run:
mcrypt -d filename.nc

And then, enter the decryption passphrase.

Source

Llexii avatar
jm flag
Thank you for your answer, I do have a question: Do I have to encrypt the file again each time I decrypt to access it ?
Rishon JR avatar
pl flag
Yes @Llexii....
Score:1
in flag

LibreOffice -- Save with Password

LibreOffice comes preinstalled on Ubuntu.

LibreOffice documents (such as Calc spreadsheets and Write documents) can be saved with a password. The contents will be encrypted using the AES-256-CBC algorithm. Once saved with a password, the document can only be opened by supplying the correct password; it is not possible to recover the password if forgotten.

LibreOffice is also able to use a GPG key if preferred.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.