DEV Community

Cover image for Encrypt your GDrive / Dropbox files. GPG for beginners!
aviiciii
aviiciii

Posted on

Encrypt your GDrive / Dropbox files. GPG for beginners!

Cloud providers like Google Drive and Dropbox encrypt your data during transfer, but they do not always encrypt it while stored on their servers. This means the service provider could technically read your files.

I’m not suggesting that they actually do this, but it’s still something many people are understandably uncomfortable with especially during the recent fiasco on requests of backdoor to the customer data from the government.

Encryption Under Threat: The UK’s Backdoor Mandate and Its Impact on Online Safety - Internet Society

Weakening encryption not only undermines personal privacy but also jeopardizes national security and global cybersecurity standards. 

favicon internetsociety.org

The simple solution to this is to save your data locally, which might not be feasible for everyone. That’s why many people still rely on cloud storage for backups.

I am sharing the method that I use to encrypt my data during cloud storage ensuring that only I can access my data.

I use GnuPG (GNU Privacy Guard) for this process — it’s free, open-source, and surprisingly simple to use.

GPG lets you take any file or folder and lock it with a password so only you can open it.

You don’t need any technical background — just a few simple commands.

By the end of this tutorial, you will have a basic understanding of how to encrypt your files and upload them to the cloud protecting your privacy.

Installation

macOS

Using Homebrew.
Install homebrew here

brew install gnupg
echo "alias gpg='gpg2'" >> ~/.zshrc && source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Or with additional tools and GUI utilities (like GPG Keychain):

brew install --cask gpg-suite
echo "alias gpg='gpg2'" >> ~/.zshrc && source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Linux

Debian / Ubuntu

sudo apt install gnupg
Enter fullscreen mode Exit fullscreen mode

Fedora

sudo dnf install gnupg
Enter fullscreen mode Exit fullscreen mode

Arch Linux / Manjaro

sudo pacman -S gnupg
Enter fullscreen mode Exit fullscreen mode

Windows

  1. Download the Gpg4win installer from: gpg4win.org
  2. Run the installer and follow the setup instructions.
  3. After installation, open Kleopatra (a GUI for GPG) or use the command line via cmd.

Verify Installation

gpg --version
Enter fullscreen mode Exit fullscreen mode

Set the Default Algorithm for encryption (AES256)

AES-256 is a strong, modern encryption algorithm. Setting it as the default ensures all your files use the strongest protection automatically.

MacOS / Linux

echo "cipher-algo AES256" >> ~/.gnupg/gpg.conf
chmod 700 ~/.gnupg
chmod 600 ~/.gnupg/gpg.conf
Enter fullscreen mode Exit fullscreen mode

Windows (in powershell)

mkdir "$env:APPDATA\gnupg" -ErrorAction SilentlyContinue
Add-Content "$env:APPDATA\gnupg\gpg.conf" "cipher-algo AES256"
Enter fullscreen mode Exit fullscreen mode

File Encryption

Encrypt

Add your files to a folder and zip them using the command or via the quick actions:

We zip the folder first because GPG encrypts files, not directories.

zip -r foldername.zip foldername/
Enter fullscreen mode Exit fullscreen mode

or compress to zip file using any software.

Then you can encrypt it with the below command

gpg --output foldername.gpg -c foldername.zip
Enter fullscreen mode Exit fullscreen mode

Enter a passphrase to encrypt your files. Do not lose this passphrase — without it, decryption is impossible. Use a password manager and write it down somewhere safe that you can access later.

Tip: Use a long passphrase (3–5 random words). It’s easier to remember and harder to crack.

Check out this video on how to create a secure passphrase (so that they can't crack your encryption, you may wanna revisit when quantum computing breaks this! so maybe check on this after every 5 years):

Upload your encrypted file to the drive

You can now upload your encrypted file to your cloud provider without any worry!

Upload only the encrypted file (example: foldername.gpg).
Never upload the unencrypted zip file.

Upload to cloud

Decrypt

gpg --output foldername.zip -d foldername.gpg
Enter fullscreen mode Exit fullscreen mode

Enter your passphrase to decrypt the zip file and extract them to view your files.

This will recreate your original ZIP file. Just extract it to get your files back.

Once your file is encrypted with GPG, nobody — not Google, not Dropbox, not even hackers — can read it without your passphrase. Thanks for reading — stay safe and encrypted!

Top comments (0)