You can also right-click on a folder or file(s) in Nautilus and select "Compress...". In the resulting window, you can expand the "Other Options" section to enter a password.
If the password field or any of the other options are not enabled, then the selected compression option does not support it. Select a different one from the list after the filename. According to the documentation:
Currently, only 7-Zip, ZIP, RAR and ARJ archives support encryption
Decrypt and extract the file from the encrypted archive:
bsdtar -xf encrypted.zip
The -a option when creating the archive makes bsdtar choose the archive format and its compression using the ending of the archive, .zip. If you don't add -a, you'll get this error message:
This will prompt for a password:
This is more insecure, as the password is entered/shown as plain text:
Warning, the standard zip encryption is very weak and is easily cracked.
Note, Use
-r
to zip directory and subdirectory recursively.Starting from Ubuntu 17.10, right-clicking and selecting "Compress" no longer has "Other Options" listed.
To resolve this, open "Archive Manager" and then drag & drop the files/folders from your File Manager into it and it will appear.
You can also right-click on a folder or file(s) in Nautilus and select "Compress...". In the resulting window, you can expand the "Other Options" section to enter a password.
If the password field or any of the other options are not enabled, then the selected compression option does not support it. Select a different one from the list after the filename. According to the documentation:
Comments and answers have mentioned the default zip encryption is weak, but since there is no code example, here is on with .7zip:
Commands explained:
7za
: Use 7zipa
: Append? / Adding files? (e
for extraction)-tzip
: Use .zip format instead of default .7z-mem=AES256
: Use AES256 encryptionfoo_file.zip
: Name of .zip filefoo_folder
: Name of folder to encryptAnswer based on: https://www.tecmint.com/7zip-command-examples-in-linux/
-r
to zip directory and subdirectoryUse
--encrypt
to secure your filesWikipedia
Encrypt
creates
your.zip.gpg
Decrypt:
To turn off password caching
More details including directories.
https://superuser.com/a/249516/27275
with bsdtar
Encrypt
a_file
, creating the encrypted archiveencrypted.zip
(you'll be prompted for a password):Decrypt and extract the file from the encrypted archive:
The
-a
option when creating the archive makes bsdtar choose the archive format and its compression using the ending of the archive,.zip
. If you don't add-a
, you'll get this error message:The metadata (filenames) of an encrypted zip can be read with
unzip -l
https://security.stackexchange.com/questions/186878/can-the-content-of-a-password-protected-zip-file-be-known
The solution, as described in that link is to double-zip it but it is really not elegant.
Also, some email providers block that kind of attachment, gmail for example.