When you need to access GitHub through the CLI
If you’ve gotten an error message when you entered your GitHub password into the CLI prompt, this is because GitHub does not allow the entering of passwords through the CLI anymore. Contrary to the prompt, you should not use your “password”, but rather, an access token here.
To create a Personal access token, log in to GitHub and click on your profile picture on the top right.
- Select Settings > Developer settings > Personal access token > Tokens (classic).
- Click Generate new token. Enter a note, e.g. AWS CodeDeploy
- Select the minimum for Expiration — e.g. 7 days if you just need to clone the repository.
- Do not forget to give the access scopes. Under Select scopes, check the minimum settings that you require, e.g. repo only if you just want to clone a respository.
- Click Generate token.
- Copy the generated token and save it in a safe place, because you will not be able to see it again.
- Paste this token when prompted in the CLI. (It is normal to see nothing actually pasted) Type Enter.
Reference: GitHub (Managing your personal access token)