Github Verified Commit

Verified Commit

둜컬 μ»€λ°‹μ—μ„œ GPGλ₯Ό μ‚¬μš©ν•΄ Verified Commit을 ν•˜κΈ° μœ„ν•œ μ„€μ • 방법

μ„€μΉ˜

brew install gnupg pinentry-mac

ν‚€ 생성

gpg --full-generate-key

μœ„ λͺ…λ Ήμ–΄ μ‹€ν–‰ ν›„ μ•„λž˜ μ˜΅μ…˜μœΌλ‘œ 생성

(1) RSA and RSA
keysize: 4096
0 = key does not expire
Real name: hyoguoo
Email address: hyoguoo@gmail.com
Comment:

μ˜΅μ…˜ 섀정을 마치면 μ•”ν˜Έλ₯Ό μž…λ ₯ν•˜λΌλŠ” λ©”μ‹œμ§€κ°€ λ‚˜μ˜€λŠ”λ°, 이 μ•”ν˜ΈλŠ” λ‚˜μ€‘ λ‹¨κ³„μ—μ„œ 졜초 컀밋할 λ•Œ μ‚¬μš©λœλ‹€.

생성 된 ν‚€ 확인

gpg --list-secret-keys --keyid-format=long
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
/Users/hyogu/.gnupg/pubring.kbx
-------------------------------
sec   rsa4096/A*************** 2023-04-25 [SC]
      B***************************************
uid                 [ultimate] hyoguoo <hyoguoo@gmail.com>
ssb   rsa4096/C*************** 2023-04-25 [E]

μœ„μ— κ°’ 쀑 A둜 μ‹œμž‘ν•˜λŠ” ν‚€κ°€ μžˆλŠ” 곳이 GPG Key ID

git config μ„€μ •

.gitconfig νŒŒμΌμ— μ•„λž˜μ˜ λ‚΄μš© μΆ”κ°€

[user]
	name = hyoguoo
	email = hyoguoo@gmail.com
	signingkey = A***************
[commit]
	gpgsign = true
[gpg]
	program = gpg

GPG Agent μ„€μ •

  • pinentry μ„€μΉ˜ μœ„μΉ˜ 확인

which pinentry-mac
  • ν™•μΈλ˜λŠ” μ„€μΉ˜ 경둜 /opt/homebrew/bin/pinentry-mac κΈ°μ€€ μ•„λž˜μ˜ λͺ…λ Ήμ–΄ μ‹€ν–‰

echo "pinentry-program /opt/homebrew/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
  • GPG Agent μž¬μ‹€ν–‰

killall gpg-agent

GiHub ν‚€ 등둝

gpg --armor --export A***************
-----BEGIN PGP PUBLIC KEY BLOCK-----

...
...
...
-----END PGP PUBLIC KEY BLOCK-----

μœ„μ˜ λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•΄ GPG Key ν™•μΈν•˜λ©΄ 좜λ ₯λ˜λŠ” λ‚΄μš©(BEGIN ~ ENDκΉŒμ§€)을 볡사 ν›„ GitHub - Settings - SSH and GPG keys - New GPG key μ—μ„œ λ³΅μ‚¬ν•œ λ‚΄μš©μ„ λΆ™μ—¬λ„£κΈ° ν›„ 등둝

컀밋 확인

졜초 컀밋 μ‹œ μœ„μ—μ„œ μ„€μ •ν•œ λΉ„λ°€λ²ˆν˜Έ μž…λ ₯ν•˜λ©΄ Verified Commit이 λœλ‹€.

μ‚¬μš© 쀑 컀밋 μ—λŸ¬κ°€ λ°œμƒν•˜λŠ” 경우

컀밋 μ‹œ μ•„λž˜μ™€ 같은 GPG μ„œλͺ… μ—λŸ¬κ°€ λ°œμƒν•  수 μžˆλ‹€.

error: gpg failed to sign the data:
gpg: signing failed: Bad CA certificate
fatal: 컀밋 였브젝트λ₯Ό μ“°λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€

μ΄λŠ” GPG 킀에 λŒ€ν•œ μ‹ λ’°(trust) μ„€μ •μ΄λ‚˜ pinentry 섀정이 μ œλŒ€λ‘œ λ˜μ–΄ μžˆμ§€ μ•Šμ€ 경우 λ°œμƒν•  수 μžˆλŠ”λ°, μ•„λž˜ 단계λ₯Ό 톡해 문제λ₯Ό ν•΄κ²°ν•  수 μžˆλ‹€.

1. GPG ν‚€ 확인 및 git에 λ“±λ‘λœ ν‚€ 일치 μ—¬λΆ€ 확인

gpg --list-secret-keys --keyid-format LONG
git config --global user.signingkey A***************

2. ν•΄λ‹Ή 킀에 λŒ€ν•œ μ‹ λ’° μˆ˜μ€€μ„ ultimate둜 μˆ˜λ™ μ„€μ •

gpg --edit-key A***************

ν”„λ‘¬ν”„νŠΈμ—μ„œ λ‹€μŒκ³Ό 같이 μž…λ ₯

trust
5

3. pinentry 경둜 확인 및 gpg-agent μ„€μ • νŒŒμΌμ— 반영

which pinentry-mac
echo "pinentry-program /opt/homebrew/bin/pinentry-mac" > ~/.gnupg/gpg-agent.conf
killall gpg-agent

μœ„μ˜ 절차λ₯Ό λͺ¨λ‘ μˆ˜ν–‰ν•œ λ’€ λ‹€μ‹œ 컀밋을 μ‹œλ„ν•˜λ©΄ λ‹€μ‹œ μ •μƒμ μœΌλ‘œ Verified 컀밋이 κ°€λŠ₯ν•΄μ§„λ‹€.

Last updated

Was this helpful?