Sign commits with SSH keys on remote servers
One can sign Git commits using an SSH Key instead of a GPG Key . To set up SSH Key signing locally, follow the documentation: GitLab Doc .
When connecting to a remote server via SSH, it’s possible to sign Git commits using a local SSH private key without storing it on the remote server. To do this:
- Enable
ForwardAgent yesin the local.ssh/configfile for the target server(s). - Store the public key in the remote server’s
.ssh/directory. - Set the signing key for the remote server’s Git user:
git config --global user.signingkey = xxx, wherexxxis the path to the stored public key file.
The main advantage of signing commits with an SSH Key is avoiding the complex and unreliable GPG agent forwarding process, relying solely on SSH agent forwarding.