思い出なんてただのゴミだ

久しぶりにgithubを利用してみたところ、pushができなかった(Git コマンドが通らなかった)

$ git push
Logon failed, use ctrl+c to cancel basic credential prompt.
Logon failed, use ctrl+c to cancel basic credential prompt.
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

エラーメッセージのページを開くと2021/08/13以降パスワード認証ができなくなった説明が書かれている。

https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

で、利用したいときはpersonal access token使ってね!とのこと。

For developers, if you are using a password to authenticate Git operations with GitHub.com today, you must begin using a personal access token over HTTPS (recommended) or SSH key by August 13, 2021, to avoid disruption. 

personal access tokenの作り方は以下に書かれている。

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

Settings → Developer settings → Personal access tokens → Generate new token

作成時に入力する項目は3つ。メモ、有効期限、許可するアクション。まあこれを設定するぐらいのことを考えている人には説明不要でしょう。

f:id:radio-keios:20220327033042p:plain

作成されたpersonal access tokenはパスワードとして使用するとコマンド使えます!

 

補足

personal access tokenは単語の頭文字をとって別名PAT。

デフォルト設定?では作成したpersonal access tokenで認証を一度行うとWindowsであれば資格情報に保存されて次にGitコマンドを実行するときは入力が不要。(personal access tokenを消したければgithub.comで無効にして、Windowsの資格情報マネージャで削除すればよい。この認証情報の管理状況については、git config credential.helperで確認できる。