我使用的是 Windows 10WSL2
(与运行Ubuntu v20
) with VSCode
.
我想将 GPG 签名的 Git Commit 发送至GitHub
in VSCode 开发容器 https://code.visualstudio.com/docs/remote/create-dev-container.
我尝试使用如下设置:
-
Install Gpg4win https://gpg4win.org/download.html在Windows中
-
安装包在WSL2
sudo apt-get install gpg gnupg gpg-agent socat
- Edit
~/.gnupg/gpg-agent.conf
in WSL2
如下:
default-cache-ttl 34560000
max-cache-ttl 34560000
pinentry-program /mnt/c/Program Files (x86)/Gpg4win/bin/pinentry.exe
- 杀死特工
gpgconf --kill gpg-agent
- 生成密钥
WSL2
gpg --full-generate-key
- 列出其中的键
WSL2
gpg --list-secret-keys --keyid-format=long
示例输出
-----------------------------------
sec rsa4096/00EF4D3F22885E4B 2021-11-20 [SC]
1234567890ABCDEF1234567890ABCDEF12345678
uid [ultimate] peter <pete[email protected] /cdn-cgi/l/email-protection>
ssb rsa4096/ABC123D7FAA52318 2021-11-20 [E]
- 设置 git 配置
WSL2
,电子邮件与 GPG 密钥匹配。
git config --global user.email "[email protected] /cdn-cgi/l/email-protection"
git config --global user.name "peter"
git config --global user.signingkey 00EF4D3F22885E4B
git config --global commit.gpgsign true
- 导出密钥并导入
Github
.
gpg --armor --export 00EF4D3F22885E4B
- 当我使用下面的 CLI 提交代码时
WSL2
,会弹出一个窗口让我输入密码,我就可以成功提交代码。
git commit -S -m "test"
但是,我无法提交代码Dev Container instance
出现以下错误:
error: gpg failed to sign the data
fatal: failed to write commit object
我怎样才能提交代码Dev Container instance
? Thanks