GitHub: Support for password authentication was removed on August 13, 2021

GitHub: Support for password authentication was removed on August 13, 2021

1 Description

yongqiang@yongqiang:~/yongqiang_work/kmeans$ git push origin master
Username for 'https://github.com': ******@163.com
Password for 'https://******@[email protected]':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ForeverStrongCheng/kmeans.git/'
yongqiang@yongqiang:~/yongqiang_work/kmeans$

2 Creating a personal access token (创建个人访问令牌)

Use a personal access token in place of a password when authenticating to GitHub in the command line or with the API.
使用 personal access token 代替密码。

2.1 About personal access tokens

Personal access tokens are an alternative to using passwords for authentication to GitHub when using the GitHub API or the command line.
使用 GitHub API 或命令行时,可使用 Personal access token 替代密码向 GitHub 进行身份验证。

GitHub currently supports two types of personal access tokens: fine-grained personal access tokens and personal access tokens (classic). GitHub recommends that you use fine-grained personal access tokens instead of personal access tokens (classic) whenever possible.
GitHub 目前支持两种类型的 personal access token:fine-grained personal access token 和 personal access tokens (classic)。GitHub 建议尽可能使用 fine-grained personal access token 而不是 personal access tokens (classic)。

  1. In the upper-right corner of any page, click your profile photo, then click Settings.

GitHub: Support for password authentication was removed on August 13, 2021_第1张图片

  1. In the left sidebar, click Developer settings.
  2. In the left sidebar, under Personal access tokens, click Tokens (classic).
  3. Select Generate new token, then click Generate new token (classic).

GitHub: Support for password authentication was removed on August 13, 2021_第2张图片

  1. Give your token a descriptive name.
  2. To give your token an expiration, select the Expiration drop-down menu, then click a default or use the calendar picker.

GitHub: Support for password authentication was removed on August 13, 2021_第3张图片

  1. Select the scopes you’d like to grant this token. To use your token to access repositories from the command line, select repo. A token with no assigned scopes can only access public information.
    选择要授予此令牌的作用域。若要使用令牌从命令行访问存储库,请选择 repo。没有指定范围的令牌只能访问公共信息。
  2. Click Generate token.

GitHub: Support for password authentication was removed on August 13, 2021_第4张图片

GitHub: Support for password authentication was removed on August 13, 2021_第5张图片

2.2 Using a personal access token on the command line (在命令行上使用 personal access token)

Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.
如果你有令牌,则可以在通过 HTTPS 执行 Git 操作时输入令牌,而不是密码。

For example, on the command line you would enter the following:

$ git clone https://github.com/USERNAME/REPO.git
Username: YOUR_USERNAME
Password: YOUR_TOKEN

Personal access tokens can only be used for HTTPS Git operations. If your repository uses an SSH remote URL, you will need to switch the remote from SSH to HTTPS.
Personal access token 只能用于 HTTPS Git 操作。如果存储库使用 SSH 远程 URL,则需要将远程 URL 从 SSH 切换到 HTTPS。

If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token.
如果没有提示你输入用户名和密码,说明您的凭据可能已缓存在计算机上。可在密钥链中更新凭据,从而用令牌替换旧密码。

3 在要求输入密码的位置改为输入生成的 token

yongqiang@yongqiang:~/yongqiang_work/kmeans$ git push origin master
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
Everything up-to-date
yongqiang@yongqiang:~/yongqiang_work/kmeans$

References

https://yongqiang.blog.csdn.net/
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

你可能感兴趣的:(Git,-,GitHub,-,Gerrit,GitHub,password,authentication)