// plain
Creating a Unix tar archive with a password is done using the tar command in combination with the gpg command.
The following example code will create a tar archive named archive.tar
and encrypt it with a password password
:
tar -cvf archive.tar file1 file2
gpg -c --cipher-algo AES256 archive.tar
The output of the command should be:
Enter passphrase:
Repeat passphrase:
The code has the following parts:
tar -cvf archive.tar file1 file2
: This creates a tar archive namedarchive.tar
containing the filesfile1
andfile2
.gpg -c --cipher-algo AES256 archive.tar
: This command encrypts the tar archivearchive.tar
using the AES256 algorithm and prompts the user for a passphrase.
onelinerhub: How do I create a Unix tar archive with a password?