Linux
Encrypt and Decrypt files with GPG in linux
Today, I would like to share about encrypting and decrypting files with GPG in linux. Let’s take a look.
GPG, known as GNU Privacy Guard (GnuPG), is an open-source command-line tool to encrypt things like files, emails, messages and so on.
Installation
GPG usually pre-installed with most of the Linux Distributions. But just in case, you can install by the following command in terminal.
sudo apt install gnupg
Usage
Generate keys
To encrypt files, you need to generate a GPG key on the system firstly.
gpg –full-generate-key
If the options to select are asked, you can read and use default values by pressing Enter.
But you will need to fill name and email.

Checking GPG keys
You can also check your key lists as follows.

Encrypting a file
Firstly, let’s create a sample text file with some text.

And let’s encrypt a file by the following command.

The recipient argument is the email you wrote when creating key.
The above command output the encrypted file with .gpg extension. You can delete original file after encryption.

And we can see the contents of the encrypted file as follow.

Decrypting a file
You can decrypt an encrypted gpg file by the following command.

This command outputs a decrypted file named decrypted_test.txt. Now you can see correct text contents of the file.
So this is all for now and for more details, I recommend to read here.
Hope you enjoy that.
By Asahi
waithaw at 2022年05月10日 10:00:00
- 2021年02月17日
- Linux
ラズベリーパイOSをPC上で動かしてみました
PCにインストール可能なRaspberryPi用のOS(Raspberry Pi Desktop for PC)があります。
今回はこのOSを VirtualBox上の仮想PC にインストールしてみます。
tanaka at 2021年02月17日 10:00:33
- 2020年01月29日
- Linux
virtualbox上のゲストOSのApacheHttpServerへアクセスする
virtualboxのゲストOSとしてCentOSをインストールしました。
今回はその上で動くApacheHttpServerへ
ホストOSのブラウザからアクセスするまでの手順をご紹介します。
tanaka at 2020年01月29日 10:00:40
- 2019年12月25日
- Linux
Raspberry PiにNOOBSを使ってOSをインストールする
tanaka at 2019年12月25日 10:00:19
Windows 10 上でbashを実行しよう
Linux用にライブラリをビルドしたかったので、
Windows10に追加された Windows Subsystem for Linux(以下 WSL) 機能を
使ってbashスクリプトを実行できる環境を作ります。
tanaka at 2019年11月20日 10:00:32