Setup workstation • Signing and verifying commits
In this exercise, the minimal necessary workstation setup for using SSH code signing is covered including:
- Checking and installing prerequisites
- Checking and generating sufficiently secure SSH certificates
- Minimal Git configuration for signing and verifying personal changes
-
Confirm minimum versions of prerequisites; otherwise install accordingly
git --version ssh -V
Afterwards, configure Git with your name and email address if necessary:
git config --global user.name "Your Name" git config --global user.email "your_email@example.com"
-
Generate a new SSH key if an existing key does not exist:
Warning Using a passphrase is strongly recommended to secure SSH keys. With SSH signing requiring use of the SSH agent, the SSH agent will ask once for the passphrase, reducing the need to enter it every time while the SSH agent is running.
ssh-keygen -t ed25519 -C "your_email@example.com" chmod 600 ~/.ssh/id_ed25519 chmod 644 ~/.ssh/id_ed25519.pub
Note If you are using a legacy system that doesn't support the Ed25519 algorithm, use 4096-bit RSA keys for this workshop:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" chmod 600 ~/.ssh/id_rsa chmod 644 ~/.ssh/id_rsa.pub
-
Start up SSH agent and add SSH private key
eval `ssh-agent` ssh-add ~/.ssh/id_ed25519
-
Create file containing SSH public key for verifying signers
awk '{ print $3 " " $1 " " $2 }' ~/.ssh/id_ed25519.pub >> ~/.ssh/allowed_signers
Note This is a simple variant of a
ssh-keygen
allowed signers file for the purposes of the workshop.For information on more advanced variants, see
ssh-keygen
ALLOWED SIGNERS documentation. -
Create local repository for workshop purposes
git init -b main simplify-signing-with-ssh-workspace cd simplify-signing-with-ssh-workspace
-
Configure SSH signing and verifying for workshop repository specifically:
git config gpg.format ssh git config user.signingkey "$(cat ~/.ssh/id_ed25519.pub)" git config gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
Note To globally configure SSH signing and verifying, use the
--global
flag:git config --global gpg.format ssh git config --global user.signingkey "$(cat ~/.ssh/id_ed25519.pub)" git config --global gpg.ssh.allowedSignersFile ~/.ssh/allowed_signers
For more information about these Git configuration options, see
gpg.ssh.allowedSignersFile
,user.signingKey
,gpg.format
.