Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
$ git config --global 'credential.https://github.com.helper' '!f() { test $1 = get && echo password=`age --decrypt ~/pat.age`; }; f'

pass

You can use pass to store your personal access token encrypted in a file. You will first have to store your GitHub username in the Git configuration file by running the following command (replace <USERNAME> with your GitHub username):

Code Block
languagebash
$ git config --global 'credential.https://github.com.username' <USERNAME>

The next step is to generate a personal access token. Go to https://github.com/settings/tokens and and click on "Generate new token". You only need to select the "repo" scope (permission). After you have generated your token, use pass to store the personal access token securely:

Code Block
languagebash
$ pass insert github.com/pat
Enter password for github.com/pat: <insert your "Personal Access Token", not your GitHub password>

Finally you must configure Git to read the personal access token from when credentials are needed for https://github.com. This is done by the following command:

Code Block
languagebash
$ git config --global 'credential.https://github.com.helper' '!f() { test $1 = get && echo password=`pass github.com/pat`; }; f'

Plain text files

Warning

This is not as secure as storing the personal access token encrypted. Any person or program who can read ~/pat.txt will be able to read your personal access token and impersonate you.

...