SSH 커밋 서명 가이드
서명되지 않은 커밋은 누구나 만들 수 있습니다. 서명은 다음을 증명합니다:
왜 커밋에 서명하나요?
- 신원 — 커밋이 키 보유자에 의해 만들어졌습니다.
- 무결성 — 서명 이후 커밋이 변경되지 않았습니다.
- 신뢰 — 플랫폼에서 "인증됨" 배지를 표시합니다.
사전 요구사항
- Git 2.34+ (
git --version) - SSH (Ed25519)
- GitHub / GitLab
1단계: 서명 키 생성
bash
# Generate an Ed25519 key for signing
ssh-keygen -t ed25519 -C "your@email.com" -f ~/.ssh/id_signing
# Verify the key was created
ls -la ~/.ssh/id_signing*2단계: Git 구성
bash
# Set the signing format to SSH
git config --global gpg.format ssh
# Point to your signing key
git config --global user.signingkey ~/.ssh/id_signing.pub
# Enable automatic commit signing
git config --global commit.gpgsign true
# Enable automatic tag signing
git config --global tag.gpgsign trueini
[gpg]
format = ssh
[user]
signingkey = ~/.ssh/id_signing.pub
[commit]
gpgsign = true
[tag]
gpgsign = true3단계: 허용된 서명자 설정
bash
# Create the allowed signers file
mkdir -p ~/.config/git
echo "your@email.com $(cat ~/.ssh/id_signing.pub)" > ~/.config/git/allowed_signers
# Tell Git where to find it
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signers4단계: 서명 및 검증
bash
# Commits are now signed automatically
git commit -m "feat: add new feature"
# Or sign a single commit explicitly
git commit -S -m "feat: signed commit"
# Sign a tag
git tag -s v1.0.0 -m "Release v1.0.0"
# Verify the last commit
git log --show-signature -1
# Verify a tag
git tag -v v1.0.05단계: GitHub / GitLab에 등록
GitHub
- Settings → SSH and GPG keys → New SSH key
- Key type: Signing Key
~/.ssh/id_signing.pub
GitLab
- Preferences → SSH Keys
- Usage type: Signing
~/.ssh/id_signing.pub
Chezmoi 통합
bash
# Add your Git config
chezmoi add ~/.gitconfig
# Add your allowed signers file
chezmoi add ~/.config/git/allowed_signers
# Add your signing key (encrypt it!)
chezmoi add --encrypt ~/.ssh/id_signingini
[gpg]
format = ssh
[user]
signingkey = {{ .chezmoi.homeDir }}/.ssh/id_signing.pub
[gpg "ssh"]
allowedSignersFile = {{ .chezmoi.homeDir }}/.config/git/allowed_signers
[commit]
gpgsign = true
[tag]
gpgsign = true문제 해결
| Problem | Solution |
|---|---|
error: unsupported value: ssh | Git 2.34+ |
error: Load key: No such file | user.signingkey |
No principal matched | allowed_signers |
| SSH agent prompt | ssh-add ~/.ssh/id_signing |
플랫폼 참고사항
| Feature | macOS | Linux | WSL |
|---|---|---|---|
| Git 2.34+ | ✅ | ✅ | ✅ |
| ssh-agent | ✅ Keychain | ✅ systemd | ✅ |
| 1Password SSH agent | ✅ | ✅ | ⚠️ |
| Chezmoi | ✅ | ✅ | ✅ |