Skip to content

Instantly share code, notes, and snippets.

@stvhay
Created January 27, 2024 15:12
Show Gist options
  • Save stvhay/90d2ea8d8d5b9b455a7a370a055151d6 to your computer and use it in GitHub Desktop.
Save stvhay/90d2ea8d8d5b9b455a7a370a055151d6 to your computer and use it in GitHub Desktop.
Configuring VSCode Dev-Containers to GPG Sign Commits into GitHub

Setting Up VSCode Git Signatures

These are instructions to create an ssh-format developer key for signing git commits, and configuring this key to be used by default, and specifying defaults to apply this signature to all git commits.

Along with specifying an identity agent in ~/.ssh/config and SSH_AUTH_SOCK environment variable, this will cause VSCode to pass along obtaining your key decryption password to the system's identity agent.

These instructions have been tested on MacOSX with 1Password set as the identity agent.

Basic Process

  1. Create a developer key using ssh-keygen. Add ssh signing key to github.

    NAME="John Doe" sh -c 'ssh-keygen -t ed25519 -f ~/.ssh/id_developer -C "$NAME: Developer Key"'
  2. Configure ~/.gitconfig on your local machine to: (Example below)

    a. Specify the ssh public signing key,

    b. to sign commits by default, and

    c. to format the git commit message to indicate the signature by default. ("git commit -s")

  3. When dev-containers makes the container, it will import these settings. Alternatively, you can edit the existing container's ~/.gitconfig.

  4. Configure vscode git Settings->Extensions->Git settings "Enable Commit Signing" and "Always Sign Off" to sign and annotate the commit message by default.

Example .gitconfig

[user]
        email = johndoe@example.com
        name = John Doe
        username = j.doe
        signingkey = << public key here >>

[init]
        defaultbranch = main

[gpg]
        format = ssh

[commit]
        gpgsign = true

[format]
        signoff = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment