- How to Create an Encrypted (Password Protected) Tar or Zip Archive in Linux
- Using tar and gpg to create a secured tar archive.
- Use 7zip to create zip format archives with secure algorithms
- Use the zip command to create an encrypted archive
- Conclusion
- How to Create a Password Protected ZIP File in Linux
- How to Create Password Protected ZIP in Linux
- How to Unzip Password Protected ZIP in Linux
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Как на tar архив пароль поставить?
- How to Create a Password Protected Zip File in Linux
- Create password protect zip file in Linux [Command Line Method]
- How To Password Protect A Folder In Linux
- Create a password protected zip file in Linux [GUI Method]
- Step 1:
- Step 2:
- Step 3:
- Step 1
- Step 2
- Step 3
- Step 4
How to Create an Encrypted (Password Protected) Tar or Zip Archive in Linux
There is often a need to encrypt and/or password protect archive files. Whether you are using them to backup data or share it across the internet, you should take the necessary steps to protect your data. In this quick tip we will examine three ways to create an encrypted and password protected archive in Linux. We will also briefly discuss some pros and cons of each method.
Using tar and gpg to create a secured tar archive.
This is the most secure way of creating an encrypted / password protected compressed archive, it is also one of the more complicated. We will use the tar command to create an archive and pipe it to the gpg command for encryption and password protection. This example specifies the AES-256 encryption algorithm.
After entering the above command you will be prompted for a passphrase.
After entering the passphrase you will be asked to repeat it. Then the archive will be created as an encrypted archive, using a secure algorithm and protected by your custom passphrase.
You will be prompted for the passphrase before the archive is extracted.
I like to always name these types of archives .tar.gz.gpg so I know how they were created. For this example we used tar, gzip and gpg. Also, it is important that you DO NOT forget the passphrase. If you do, there is no way to recover the data.
Use 7zip to create zip format archives with secure algorithms
This is just as secure as the first option since it supports the same AES-256 encryption algorithm, although it does require you put the passphrase or “secret” on the command line, which I am not a fan of. It is also not as convenient because most systems do not come with the P7zip package installed.
To install P7zip on Red Hat, or RH variants like CentOS or Fedora:
On Debian based systems such as Ubuntu:
To create the archive, use the command below, replace “PASSPHRASE” with your own secret passphrase.
To extract the zip archive use the following:
Use the zip command to create an encrypted archive
The zip command provides options to allow you to encrypt archives. It uses a known insecure PKZIP algorithm and also requires you to add your passphrase on the command line. The benefit of this method is both Linux and Windows folks can extract the archive without any additional software.
Simply add the –password option to the zip command like so:
Remember to replace PASSPHRASE with your password.
To extract the archive, use the normal unzip utility. The only difference is you will be asked for a password.
Conclusion
So there you have my three favorite ways to created encrypted archives. There are plenty more ways to accomplish this (openssl, gpg-zip, bcrypt) and some are better than others. If you data is really important, I suggest you read up on the different algorithms and signing methods that are out there and decide for yourself which is right.
Whatever method you use it is important to NOT forget your passphrase.
Источник
How to Create a Password Protected ZIP File in Linux
ZIP is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives.
In this post, I will show you how to create a password protected zip file on the terminal in Linux. This will help you learn a practical way of encrypting and decrypting contents of zip archive files.
First install zip utility in your Linux distribution using the package manger as shown.
How to Create Password Protected ZIP in Linux
Once installed, you can use the zip command with -p flag to create a password protected zip archive called ccat-command.zip from the directory of files called ccat-1.1.0 as follows.
Create Password Protected Zip File
However, the above method is absolutely insecure, because here the password is provided as clear-text on the command line. Secondly, it will also be stored in the history file (e.g
.bash_history for bash), meaning another user with access to your account (more especially root user) will easily see the password.
Therefore, try to always use the -e flag, it shows a prompt allowing you to enter a hidden password as shown.
Create Password Protect Zip Archive
How to Unzip Password Protected ZIP in Linux
To unzip and decrypt the content of the archive file called ccat-command.zip, use the unzip program and provide the password you entered above.
Decrypt ZIP Archive
That’s It! In this post, I described how to create a password protected zip file on the terminal in Linux. If you have any queries, or other useful related tip/tricks to share, use the comment form below ping us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Как на tar архив пароль поставить?
Если тебе захотелось зашифровать файл, то используй программы для шифрования файлов.
Пароль на архив мне захотелось..
gpg -c твой_архив.tar.gz
tar таких средств, насколько я знаю, не имеет.
Пароль — подразумевает шифрование, а архиватор шифровать не умеет, а вот gpg не умеет архивировать, но умеет шифровать. Используй их вместе
Тебе подойдет zip:
zip -P password file.zip file
tar занимается архивированием, а не шифрованием. Для шифрования можно использовать openssl, gpg.
Вот тебе несколько способов на любой вкус.
пароль на архив это и есть шифрование. tar склеивает, gzip жмет, gpg шифрует.
Поставь виндовс, он кажется умеет пароли на архивы.
и rar и 7zip умеет
вопрос конкретно о tar был.
Прятный бонус, gpg сжимает автоматом данные.
Я и говорю, поставь виндовс.
А tar не умеет, тар умеет собирать из нескольких файлов один. Ещё есть gzip, который умеет сжимать файлы. Ещё есть openssl и gpg, которые умеют шифровать файлы. И для расшифровки тебе таки понадобится пароль. Но из твоих комментариев я так и не понял, нужно ли тебе что-то шифровать и что этот твой пароль вообще должен делать.
Для любителей понаставить левых тегов в аду есть специальные пытки. Ты готов к ним?
TAR умеет только делать из кучи файлов один (с сохранением путей, атрибутов, прав доступа и т. д.). Он не умеет ни сжимать, ни шифровать (постановка пароля на архив имеет смысл только с шифрованием). Подразумевается, что этим будут заниматься другие программы. Например, после слияния файлов с помощью tar может быть запущен gzip.
Источник
How to Create a Password Protected Zip File in Linux
Last updated October 29, 2020 By Abhishek Prakash 13 Comments
Brief: This simple tutorial shows you how to create a password protected zip file in Linux both in command line and graphical way.
We have seen how to password protect folders in Ubuntu earlier. We have also seen encrypted text editor for Linux. Today, we’ll see how to create password protected zipped files in Linux, in both command line and graphical way.
I am using Ubuntu in this tutorial but you can use any Linux distribution that uses Nautilus (now called Files) file manager for the graphical part. Command line steps are the same for any Linux distribution.
There are several ways you can encrypt zip file in Linux. In fact, there are dedicated command line tools for this task, but I am not going to talk about those. I am going to show you how to password protect a zip file without installing a dedicated tool.
Create password protect zip file in Linux [Command Line Method]
First thing first, make sure that you have zip support enabled in your Linux system. Use your distribution’s package manager and try to install it. If its not installed already, it will be installed.
In Debian/Ubuntu, you can use this command:
Now, let’s see how to password protect a zip file in Linux. The method is almost the same as creating zip folder in Linux. The only difference is the use of option -e for encryption.
The -r option is used to recursively look into directories. The -e option is for encryption.
You’ll be asked to enter and verify the password. You won’t see the password being typed on the screen, that’s normal. Just type the password and press enter both times.
Here’s what the process looks like on the screen:
zip -re my_zip_folder.zip agatha.txt cpluplus.cpp test_dir
Enter password:
Verify password:
adding: agatha.txt (deflated 41%)
adding: cpluplus.cpp (deflated 4%)
adding: test_dir/ (stored 0%)
adding: test_dir/myzip1.zip (stored 0%)
adding: test_dir/myzip2.zip (stored 0%)
adding: test_dir/c.xyz (stored 0%)
Do note that if someone tries to unzip this file, he/she can see the content of the folder such as which files are there in the zipped file. But the files cannot be read.
Recommended Read:
How To Password Protect A Folder In Linux
Have secrets? Keep them safe by locking folders with password in Linux.
Create a password protected zip file in Linux [GUI Method]
I have created a password protected zip file in Ubuntu 18.04 here but you can use the same steps on any Linux distribution with GNOME desktop environment.
Step 1:
Search for Archive Manager and open it.
» data-medium-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?fit=300%2C86&ssl=1″ data-large-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?fit=800%2C230&ssl=1″ loading=»lazy» width=»800″ height=»230″ src=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=800%2C230&ssl=1″ alt=»Archive Manager Ubuntu» srcset=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?w=800&ssl=1 800w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=300%2C86&ssl=1 300w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/archive-manager-ubuntu.jpg?resize=768%2C221&ssl=1 768w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Archive Manager
Step 2:
Drag and drop the file(s) you want to compress into a zip file. Select Create Archive option here.
Create a zip file
» data-medium-file=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?fit=300%2C184&ssl=1″ data-large-file=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?fit=800%2C491&ssl=1″ loading=»lazy» width=»800″ height=»491″ src=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=800%2C491&ssl=1″ alt=»Create Archive Ubuntu 1″ srcset=»https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=800%2C491&ssl=1 800w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=300%2C184&ssl=1 300w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?resize=768%2C471&ssl=1 768w, https://i0.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-archive-ubuntu-1.jpg?w=1053&ssl=1 1053w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Create a zip file
Step 3:
In here, choose the type of compressed file. It will be .zip in my case. You’ll see the “Other Options”, click on it and you’ll see the password field. Enter the password you want and click on the Save button.
Create Password Protected Zip file
» data-medium-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?fit=300%2C182&ssl=1″ data-large-file=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?fit=800%2C485&ssl=1″ loading=»lazy» width=»800″ height=»485″ src=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=800%2C485&ssl=1″ alt=»Creating Password Protected Zip file in Ubuntu Linux» srcset=»https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=800%2C485&ssl=1 800w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=300%2C182&ssl=1 300w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?resize=768%2C465&ssl=1 768w, https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/01/create-password-protected-zip-ubuntu.jpg?w=1046&ssl=1 1046w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Create Password Protected Zip file
That’s it. You have successfully created a password protected zip file in Ubuntu Linux graphically. The next time you want to extract it, it will ask for a password.
» data-medium-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?fit=300%2C176&ssl=1″ data-large-file=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?fit=800%2C469&ssl=1″ loading=»lazy» width=»800″ height=»469″ src=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=800%2C469&ssl=1″ alt=»Password Protected Zip file in Ubuntu» srcset=»https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=800%2C469&ssl=1 800w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=300%2C176&ssl=1 300w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?resize=768%2C451&ssl=1 768w, https://i2.wp.com/itsfoss.com/wp-content/uploads/2016/01/password-protected-zip-ubuntu.jpg?w=852&ssl=1 852w» sizes=»(max-width: 800px) 100vw, 800px» data-recalc-dims=»1″/> Password Protected Zip file in Ubuntu
If you are using Ubuntu 16.04 with Unity desktop environment, things will be slightly different. Click on the next section to see the steps for Unity desktop.
To follow this tutorial, you just need to make sure that you are using Nautilus/Files file explorer. If you are using Fedora, Ubuntu Unity, or any other Linux distribution with GNOME as its desktop environment, you have Nautilus.
Step 1
Right click on file(s) and/or folder(s) and click on Compress:
Select the compression format you want to choose. There are several formats available but you cannot use all of them for password protecting the files.
Step 2
I advise to use the .zip format. After selecting the compression format, click on the Other Options.
Step 3
You’ll see option of entering password in Other Options. If the compression format you selected doesn’t support encryption, this Password area would be greyed out.
It may also happen that you’ll have to install the compression utility to use the encryption. For example, if you do not have RAR installed, password option will not be available.
Step 4
Enter a suitable password and click on Create:
Compression takes time based on the size of the file or directory. You’ll see a message like this when the files are compressed successfully:
The compressed file thus created is password protected. If you try to extract it, it will ask you to enter the password:
As you can see, no one (in normal ways) can extract this file without the password. Congratulations, you just learned how to encrypt zip files in Ubuntu Linux.
Just for your information, double clicking on the password protected directory might give the impression that you may access the encrypted directory without a password, but you cannot actually read those files.
I hope this quick tutorial helped you to create password protected zip files in Linux. In coming days, we shall see how to password protect a directory in Linux and how to break the encryption. Stay tuned 🙂
Like what you read? Please share it with others.
Источник