详解Linux GPG加密

树叶云

GPG 可以用来签署和加密数据。方便发送和接收方进行数据加密和对方身份的确认。GPG 使用对称加密技术来加密大段内容,而采用非对称加密技术来交换对称加密的秘钥。

在Ubuntu下,用GPG命令可以实现文件的加密和解密,而且GPG基本上每个发行版都会预装。

gpg -c file # 加密一个文件,会生成file.gpg
gpg file.gpg # 解密file.gpg 还原成file文件

常用基本命令

gpg --gen-key # 生成秘钥对
gpg --list-keys # 查看已有的秘钥
gpg --delete-secret-keys <...> # 删除私钥
gpg --delete-key <...> # 删除公钥
gpg --armor --output public.key --export 
  
    
   # 导出私钥 gpg --armor --output private.key --
   export-secret-keys 
   
     
    # 导出公钥 gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 
    
      
     # 将公钥上传服务器

生成秘钥时候如果出现下面的提示后卡住

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

手动安装一下面的软件即可解决问题!

sudo apt install rng-tools

下面是我在本地生成秘钥对并将公钥发到了服务器

公钥服务器:http://keys.gnupg.net/、http://keyserver.ubuntu.com:11371/

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/212979.html<

(0)
运维的头像运维
上一篇2025-04-11 03:00
下一篇 2025-04-11 03:02

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注