How to Encrpyt a File using GnuPG.
Skyie
May 27 2017

1  965 {{tagitem.name}}
In this tutorial, i will be showing you guys how to Encrypt a file using GnuPG on a xShellz shell (paid/free)


1. Make a new Directory. (Its always a good habit to make a new directory when your testing new things)

mkdir test1


2. Change your directory to "Test1". (Now change your directory to the newly created one)

cd Test1


3. Create a new file named "Encrypt.sh". (Now we should create a new file named Encrypt.sh, This will be the file which does the encryption)

> Encrypt.sh


4. Edit the file "Encrypt.sh". (Now edit the file using your favourite editor, In this tutorial we will be using Nano Editor)

nano Encrypt.sh


5. Add the encryption script to text file. (Now we will add the encryption script to the text file through nano editor. Copy/Paste the following script down below to the Encrypt.sh file)

--------------------------------------------------------------------------------------------------------------

#!/bin/bash

echo "Welcome, I am ready to encrypt a file/folder for you"

echo "currently I have a limitation, Place me to thh same folder, where a file to be

encrypted is present"

echo "Enter the Exact File Name with extension"

read file;

gpg -c $file

echo "I have encrypted the file successfully..."

echo "Now I will be removing the original file"

rm -rf $file [/li]

----------------------------------------------------------------------------------------------------------------

6. Save the script to the file. (Now save the script to the file and exit from the editor)

CTRL+X (Hold Control key and press X)


7. Change the files access permissions to 755. (Now change the file access mode to 755, We use the command chmod to change/revoke a files permissions)

chmod 755 Encrypt.sh


8. Add files to the Directory. (Now add/move the file which you want to encrypt to the directory we created "text1")

9. Execute the command "./Encrypt.sh" (Now execute the ./Encrypt.sh command from the console. You will be promopted to state the file name and then to enter the password/passphrase twice)

./Encrypt.sh




10. File is Encrypted now. (Your file now encrypted, You can check if the file is encrypted by opening it)



So after encrypting a file what you need? Obviously! decrypting the file, Which i will be showing you guys in the next tutorial. Don't worry I am not leaving you guys in the middle. Click here for the Decryption tutorial.

Have Doubts/Questions? Please comment down below on the post or email me at BLinuxYT[at]outlook.com

@Black Linux/Skyie/AutoBotIRC - Buuuuurp Geeky!
Excellent tutorial @AutoBotIRC. Very clean and helpful.
Staff StephenS    May 27 2017

Please Login or Sign Up to leave a reply.