Skip to content

Instantly share code, notes, and snippets.

@brenopacheco
Last active September 8, 2023 02:11
Show Gist options
  • Save brenopacheco/cc9afeb3090fa9c91e24e03073b9f35e to your computer and use it in GitHub Desktop.
Save brenopacheco/cc9afeb3090fa9c91e24e03073b9f35e to your computer and use it in GitHub Desktop.
storing git credentials with gpg and .netrc

storing git credentials with gpg and .netrc

  1. set up git credential helper in .gitconfig
    [credential]
        helper = /usr/share/git/credential/netrc/git-credential-netrc.perl
  1. add login configuration to .netrc
    machine github.com
      login <email (or username?)>
      password <password>
      protocol https
    machine bitbucket.org
      login <username (not email!)>
      password <password>
      protocol https
  1. encrypt .netrc (output MUST be .netrc.gpg otherwise helper won't decrypt)
    gpg -ea --output .netrc.gpg .netrc
    shred .netrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment