How to use GPG to encrypt and decrypt files in Linux system?

WBOY
Release: 2024-02-24 13:52:02
forward
1206 people have browsed it

Linux系统如何使用 GPG 加密和解密文件?

In Linux systems, you can use GPG (GNU Privacy Guard) to encrypt and decrypt files. GPG is an open source encryption software used to ensure the confidentiality of files and communications. Here are the basic steps to encrypt and decrypt files using GPG:

Encrypted file:

  1. Open a terminal and log in as the user logged into the Linux system.
  2. Generate GPG key pair:

    • Run the following command to generate a GPG key pair:

      gpg --gen-key
      Copy after login
    • Follow the prompts to provide the necessary information such as name, email address, and password. This information will be used to generate a key pair.
  3. Encrypted file:

    • Run the following command to encrypt the file:

      gpg -e -r <收件人ID> <要加密的文件>
      Copy after login
    • Replace
      <Recipient ID> is the GPG key ID of the recipient, which can be its name, email address, or fingerprint of the key.
    • Replace
      <File to be encrypted> is the path and name of the file to be encrypted.
  4. GPG will encrypt the file using the recipient's public key and generate an encrypted file in the current directory.

Decrypt file:

  1. Open a terminal and log in as the user logged into the Linux system.
  2. Decrypt file:

    • Run the following command to decrypt the file:

      gpg -d <要解密的文件>
      Copy after login
    • Replace
      <File to be decrypted> is the path and name of the file to be decrypted.
  3. GPG will ask you to enter your private key password. After entering the correct password, GPG will decrypt the file and output it to the terminal.

Through the above steps, you can use GPG to encrypt and decrypt files in Linux systems. Please note that encrypted files cannot be accessed by unauthorized persons and only those with the correct private key can decrypt the files. For security reasons, keep your private keys safe and protect them with a strong password.

The above is the detailed content of How to use GPG to encrypt and decrypt files in Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template