Versions Compared

Key

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

...

You can use GnuPG (GPG) to store the your personal access token encrypted in an encrypted 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):

...

Finally you must configure Git to decrypt and read the personal access from the file ~/pat.gpg 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=`gpg --decrypt ~/pat.gpg`; }; f'

age

You can use age 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 age to encrypt it and store it in a you PAT in an encrypted file. To encrypt the file personal access token using a passphrase and storing the result in a file, run the following command (replacing <PAT> with your personal access token):

Code Block
languagebash
$ echo '<PAT>' | age --passphrase > ~/pat.age 

When using applicable Skara CLI tools set the GIT_TOKEN environment variable to the decrypted value, for exampleFinally you must configure Git to decrypt and read the personal access from the file ~/pat.age when credentials are needed for https://github.com. This is done by the following command:

Code Block
languagebash
$ GIT_TOKEN=$(age git config --global 'credential.https://github.com.helper' '!f() { test $1 = get && echo password=`age --decrypt ~/pat.age) git pr listage`; }; 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.

...