Where to store the personal access token from GitHub?

后端 未结 5 1279
难免孤独
难免孤独 2021-01-30 02:45

Is it necessary to store the personal access token somewhere locally on the machine after generating it in GitHub?

If yes, is there any preferred way where it could be

5条回答
  •  被撕碎了的回忆
    2021-01-30 03:46

    I like to keep them encrypted within the repository and load them using .envrc (https://direnv.net/)

    For doing this I use ssh-vault to encrypt the data using my ssh keys that GitHub already is exposing, for example:

    echo MY_TOKEN="secret" | ssh-vault -u  create > my-encypted-vars.ssh
    

    Then the content of .envrc looks something like this:

    echo "Enter ssh key password"
    context=$(ssh-vault view $HOME/projects/my-encrypted.ssh | tail -n +2)
    export ${context}
    

    This will decrypt the data in my-encrypted-vars.ssh file and set MY_TOKEN into my environment variables every time I cd into the project dir.

    By doing this tokens/variables are stored "safely" and always ready to use as environment variables

提交回复
热议问题