How to Encrpyt a File using GnuPG.
May 27 2017

1  3K+ {{}}
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 "". (Now we should create a new file named, This will be the file which does the encryption)


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


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 file)



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

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 "./" (Now execute the ./ command from the console. You will be promopted to state the file name and then to enter the password/passphrase twice)


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]

@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.