![]() Gpg can be used to add a layer of encryption to the process. In that article we noted that such a method of transferring data was not secure because it lacked encryption. In a Tips & Tricks with Netcat command article we showed you how to use netcat to transfer directories from one computer to another over the network. $ for i in * do tar -cvzf - "$i" | gpg -c -passphrase yourpassword > "$i".tar.gpg doneĮncrypting netcat archive transmissions over the network. Simply cd to the directory that contains the subdirectories you want to create individual archives for and enter the following command. What if we have a directory filled with multiple subdirectories, but we want to create a separate encrypted archive for each directory? We can use a bash for loop to help us accomplish that. The above examples assume that we want to create a single encrypted archive based on a single directory. Create multiple individual encrypted archives of directories The -x flag is used to extract the archive that is piped in from gpg, -v is for verbose extracting, -z is to decompress the archive and -f - specifies that the file being unarchived is being piped in. ![]() The -d flag tells gpg that we want to decrypt the contents of the .gpg file. In order to decrypt, decompress and extract this archive later you would enter the following command. $ tar -cvzf - folder | gpg -c -passphrase yourpassword > .gpg If you don’t like this behavior and prefer to specify the passphrase within the command you may add the -passphrase flag after -c as shown below. After entering this command you will be prompted to enter the passphrase that you want to use to encrypt the data. Finally, we redirect the output to a file named .gpg with >. We then proceed to do just that and gpg‘s -c flag indicates that we want to encrypt the file with a symmetric cipher using a passphrase as we indicated above. The only difference is that instead of specifying a filename for our archive within the tar command we specify - so that we can pipe the output of the tar command into gpg. $ tar -cvzf - folder | gpg -c > .gpgĪll of the tar flags are the same as in our previous example. To create an encrypted compressed archive of a directory named folder enter the following command. We have already looked at using key based encryption in a article How to Encrypt and Decrypt Individual Files With GPG, so we will look at password based encryption here. You may choose to use key based encryption, password based encryption or a combination of both. Now that we have reviewed creating an archive with tar, let’s look at how we can create an encrypted archive by adding gpg to the mix. The -x flag is used to extract the archive, -v is for verbose extracting, and -z is to decompress the archive. In order to decompress and extract this archive later you would enter the following command. The -c flag is used to create the archive, -v is used for verbose output so that we have visual feedback which lets us know this is happening and -z is used to compress the archive so that the life size is smaller. a quick dirty method for copying these archives over a network by adding netcat to the pipeline.to create multiple individual encrypted archives of directories.to create encrypted compressed archives by using tar with gpg in a pipeline.to create compressed archives using tar.Gpg is a very versatile cryptographic tool which allows you to encrypt files, encrypt e-mail, and verify the integrity of signed files. In the above scenarios that we mentioned it is often desirable to have encryption in order to secure your data. These tarballs are pretty much the standard go-to format for archives on GNU/Linux, however they are not encrypted. ![]() Tar.gz files, or compressed tarballs, are created using the tar command. Another possible scenario is that you may want to privately share content with a friend or colleague over the web or through cloud storage. ![]() You may want to create an encrypted backup of your personal files. There are many reasons why you may want to create compressed encrypted file archives. ![]()
0 Comments
Leave a Reply. |