Linux 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 <..[email protected]> # 删除私钥
gpg --delete-key <..[email protected]> # 删除公钥
gpg --armor --output public.key --export <uid> # 导出私钥
gpg --armor --output private.key --export-secret-keys <uid> # 导出公钥
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys <PUBLIC_KEY_ID> # 将公钥上传服务器

在这里插入图片描述
在这里插入图片描述
生成秘钥时候如果出现下面的提示后卡住

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/
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43833642/article/details/106854772
gpg