To work with GitHub from your local system, you must establish a secure authentication method. As of 2021, GitHub no longer supports password authentication for local repository access. Instead, you can utilize one of the following authentication methods:
gh auth login
) The standard method using GitHub's Command Line Interface (gh
). It facilitates much of what you'd do on GitHub outside of the typical git
operations. This method offers easy setup and caching of your credentials without needing a personal access token. Highly recommended.Personal Access Token Cloning a repository from GitHub using a URL demands a personal access token. You generate this token on GitHub with specified permissions, and it can be used across multiple local setups.
Although this method is possible, it is not recommended. For detailed instructions, you can search online or refer to GitHub's official documentation. Preferably, opt for the gh auth login
method.
gh auth login
, it's a common professional approach also used for secure access for programs. Consider setting this up at some point.This is a user-friendly way to authenticate without repeatedly entering your username and password. Enter the following in WSL:
During authentication, the command will prompt you with a series of questions. Default answers are provided, so simply press "Enter" to accept each:
Following the prompts, you'll receive a one-time code. (Note: Your code will differ from the example.)
For WSL users: If the following error arises from the system not opening the browser, simply open any browser (even on another device) and sign into your GitHub account.
To authenticate:
Once authenticated, you'll see a confirmation message in WSL with your GitHub username:
You've now securely authenticated with GitHub. Your git
operations will not require repeated username or token inputs.
BTW, this process resembles "Device Code Flow" or "Device Authorization Grant" from OAuth 2.0.