Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Encrypting a single file with GPG from the CLI

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2020
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 138 times
Been thanked: 204 times

Encrypting a single file with GPG from the CLI

#1 Post by Hallvor »

What is GPG?
GnuPG is a complete and free implementation of the OpenPGP standard as defined by RFC4880 (also known as PGP). GnuPG allows to encrypt and sign your data and communication, features a versatile key management system as well as access modules for all kinds of public key directories. GnuPG, also known as GPG, is a command line tool with features for easy integration with other applications.

Why use encryption?
Even if you have nothing to hide, using encryption helps protect the privacy of people you communicate with, and makes life difficult for bulk surveillance systems.

Encrypting a file with a password
To encrypt a file, open a terminal in the directory of the file you want to encrypt. Encrypt the file using the command

Code: Select all

$ gpg -c thenameofmyfile
If the file you want to encrypt is called "mypasswords.odt", you can use the command:

Code: Select all

$ gpg -c mypasswords.odt
You will then be asked to enter a password twice:

Code: Select all

Enter passphrase:
Repeat passphrase:
The resulting encrypted file will then get the extension .gpg, like this: "mypasswords.odt.gpg"

Decrypting the file
To decrypt the file, use the following command:

Code: Select all

$ gpg thenameofmyfile
Like this:

Code: Select all

$ gpg mypasswords.odt.gpg
You will then be asked to enter your password. Upon entering your password, the file will be decrypted.

Several files or folders can be encrypted using the same method. Just use tar them (or whatever) to put them all into a single archive first.

See also:
https://gnupg.org/
https://en.wikipedia.org/wiki/GNU_Privacy_Guard
http://www.cyberciti.biz/tips/linux-how ... sword.html
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

Post Reply