Generate asymmetric key using the command below:
cd ~/.ssh
ssh-keygen -t rsa
Add the public key as auth key in github account's settings
Add private key to ssh agent:
# first of all, activate ssh agent
eval ssh-agent $SHELL
# add key to agent
cd ~/.ssh
ssh-add ./key
# make sure the key was added
ssh-add -l
Check connectivity with authentication:
ssh -T [email protected]
Add public key as signing key in github account's settings
Update git config:
git config [--global] gpg.format ssh
git config [--global] commit.gpgsign true
git config [--global] tag.gpgsign true
git config [--global] user.signingkey ~/.ssh/key.pub
Check signed commit by:
git commit -am "test signed commit" --allow-empty
Optional, if you encounter an error:
git config --global gpg.program "the/path/to/program"
add ~/.ssh/config to make it automatically connect, see man 5 ssh_config
for futher information
and see stackoverflow for multiple credential
Example config
:
Host reyuki.github.com
HostName github.com
IdentityFile ~/.ssh/reyuki
Host myself.github.com
HostName github.com
IdentityFile ~/.ssh/myself
Host serper
HostName 192.168.18.12
User root
Port 22
IdentityFile ~/.ssh/serper
Footnotes:
- This guide not providing reassign commit that already committed without even verified
- And also doesn't provide signing in file scope
- Make sure your remote url using ssh protocol
for HTTP version, see the docs