• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How to Encrypt a File for Transport with GnuPG on Windows WSL (Ubuntu)

By Abhishek Ghosh April 29, 2024 11:18 am Updated on April 29, 2024

How to Encrypt a File for Transport with GnuPG on Windows WSL (Ubuntu)

Advertisement

This guide teaches you how to encrypt a file such as text file before transporting them over the internet to your friend so that nobody else can open and read it. This is essential for maintaining data privacy and security.
GnuPG (GNU Privacy Guard) is a powerful open-source encryption tool that allows users to encrypt and decrypt files using public-key cryptography. To follow this guide, you need to have:

  • Either a PC running Ubuntu Linux
  • Or a server running Ubuntu Linux
  • Or a Windows PC with WSL (Ubuntu) configured
  • Or an Android phone with Termux installed

In any case, you will be able to run a terminal window with apt package management.

 

Steps to Encrypt a File for Transport with GnuPG

 

GnuPG is required to be installed on your Ubuntu system. If not installed, you can install it using the following command:

Advertisement

---

Vim
1
sudo apt-get install gnupg

Generate a Key Pair

Before encrypting files, you need to generate a key pair consisting of a public key and a private key. The public key is used to encrypt files, while the private key is used to decrypt them. To generate a key pair, follow these steps. Run the following command to generate a new key pair:

Vim
1
gpg --gen-key

You’ll receive this prompt:

Vim
1
2
3
4
5
6
Please select what kind of key you want:
  (1) RSA and RSA (default)
  (2) DSA and Elgamal
  (3) DSA (sign only)
  (4) RSA (sign only)
Your selection? 1

How to Encrypt a File for Transport with GnuPG on Windows WSL Ubuntu

Select (1) RSA and RSA. Next, it will ask you the key size. A key size of 2048 bits is still considered adequate:

Vim
1
What keysize do you want? (2048) 2048

Next, it will ask for an expiration period. That is a complicated topic and will be discussed in a separate article. For ordinary works and testing purposes, you can choose no expiration:

Vim
1
2
3
4
5
6
7
Please specify how long the key should be valid.
  0 = key does not expire
  <n> d = key expires in n days
  <n> w = key expires in n weeks
  <n> m = key expires in n months
  <n> y = key expires in n years
Key is valid for? (0) 0

Next, it will ask your name, email, comment and a password:

Vim
1
2
3
Real name: Abhishek Ghosh
Email address: admin@abhishekghosh.com
Comment: Example for thecustomizewindows.com

Use a difficult-to-guess password. Once the key pair is generated, your public key will be stored in the GnuPG keyring. GnuPG maintains two keyrings, one for public keys and one for private keys. Whenever we use a private key to decrypt, GnuPG will ask us for the passphrase.

These keys are stored under ~/.gnupg directory.

Import Recipient’s Public Key

If I intend to encrypt files for you as recipient, you’ll need to export your public key:

Vim
1
2
# you
gpg -o yourpublickey.asc --export -a you@example.com

It will go to the keyring. I have to import your public key into my keyring:

Vim
1
2
# me
gpg --import yourpublickey.asc

But your foe may have replaced your public key with your public key while it was in transit to me. To verify that key is the public key, I will check the fingerprint of the key, phone you and read the fingerprint to match:

Vim
1
2
3
4
5
gpg --fingerprint you@example.com
pub   3348T/694F0DS8 2024-04-25
      Key fingerprint = AD5F 2TB3 81V0 C6SA 69ED  597F 9Q15 887B 998E 87W9
uid   You <you@example.com>
sub   8098T/7S17R3Q0 2024-03-29

If you agree that it is your key, then I will sign your key with my private key to make it trusted:

Vim
1
gpg --sign-key you@example.com

Encrypt a File

Now, I can encrypt any file which I will send to you:

Vim
1
2
echo "secret message to you" > message.txt
gpg -o message.encrypted -r you@example.com -e message.txt

You can run this kind of command to decrypt it:

Vim
1
gpg -o message.txt -d message.encrypted

Encrypting files with GnuPG is a straightforward process that helps protect sensitive data during transport. By following the steps outlined in this guide, you can encrypt files with ease and ensure that only authorized recipients can access the encrypted data. Remember to securely store your private key and passphrase to maintain the confidentiality and integrity of your encrypted files.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Encrypt a File for Transport with GnuPG on Windows WSL (Ubuntu)

  • How GNU Privacy Guard (GPG) Works – With Example

    GNU Privacy Guard or GPG, is a free cryptography system used to encrypt and decrypt data, as well as to generate & verify digital signatures.

  • GNU Privacy Guard (GPG) For Secure Cloud Computing

    GNU Privacy Guard (GPG) is used for code signing in Free Software. For secure Cloud Computing, GPG can be used for Emails and Messaging.

  • How to Use the gpg-agent in GnuPG

    The gpg-agent is an important part of GnuPG that plays a similar role to the ssh-agent in OpenSSH. It has been integrated into the system as of GnuPG version 2.0.x and performs several tasks related to the management of keys and passphrases. One of the main functions of the gpg-agent is to store private key […]

  • Encrypt Decrypt any file or folder from right click context menu in Windows 7

    You can add Encrypt or Decrypt option in Windows 7 right click context menu. Thus any file or folder can be Encrypted or Decrypted on single click.Here is how you can do it.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy