I am using Windows10 WSL2
(running with Ubuntu v20
) with VSCode
.
I want to send GPG-signed Git Commit to GitHub
in VSCode Dev Container.
I try with the setup like below:
Install Gpg4win in Windows
install packages in
WSL2
sudo apt-get install gpg gnupg gpg-agent socat
- Edit
~/.gnupg/gpg-agent.conf
inWSL2
as below:
default-cache-ttl 34560000
max-cache-ttl 34560000
pinentry-program /mnt/c/Program Files (x86)/Gpg4win/bin/pinentry.exe
- kill the agent
gpgconf --kill gpg-agent
- generate keys in
WSL2
gpg --full-generate-key
- list the keys in
WSL2
gpg --list-secret-keys --keyid-format=long
example output
-----------------------------------
sec rsa4096/00EF4D3F22885E4B 2021-11-20 [SC]
1234567890ABCDEF1234567890ABCDEF12345678
uid [ultimate] peter <[email protected]>
ssb rsa4096/ABC123D7FAA52318 2021-11-20 [E]
- set git config in
WSL2
, email is matched with the GPG key.
git config --global user.email "[email protected]"
git config --global user.name "peter"
git config --global user.signingkey 00EF4D3F22885E4B
git config --global commit.gpgsign true
- export the keys and import in
Github
.
gpg --armor --export 00EF4D3F22885E4B
- When I commit the codes with CLI below in
WSL2
, there is a pop up for me enter the passphrase and I can commit the codes successfully.
git commit -S -m "test"
However, I cannot commit the codes in the Dev Container instance
with the error below:
error: gpg failed to sign the data
fatal: failed to write commit object
How can I commit the codes in Dev Container instance
? Thanks
CodePudding user response:
It turns out I should not install gnupg2
in my Dev Container instance
.