LoginSignup
2
1

More than 1 year has passed since last update.

パスワード認証廃止の解決(アクセストークン生成)

Last updated at Posted at 2021-09-21

コマンドラインでgit pushしようとしたらいつもは入力しないユーザーネームを求められたので入力し、パスワードを入力したらエラーになりました。要約すると、

パスワード認証のサポートは2021年8月13日に削除されました。
代わりに個人用アクセストークンを使用してください。
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ を参照してね。

ユーザ名とパスワードではなくアクセストークンを使用してね。
とのことでした。

$ git push origin ブランチ名
Username for 'https://github.com': ユーザー名記入
Password for 'https://ユーザー名@github.com': パスワード記入
↓ここからエラー
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.
fatal: Authentication failed for 'https://github.com/ユーザー名/リポジトリ名.git/'

調べてみたところ、色々な記事が出てきて参考にしながら解消していきます。
早速設定してみます。

取得手順

まず、
githubにログイン>Settings>Developer settings>Personal access tokens>Generate new token
ここまでのリンク→(https://github.com/settings/tokens) の流れで進み、パスワードを入力して新しいトークンの設定画面に入る。

設定画面

・noteに新しいトークンの名前を入力。
・有効期限を設定。
・権限を設定する。
---今回はrepo(リポジトリ)にだけチェック。
---他のチェックは後日追記。
・generate token(トークンを生成する)をクリック。
・トークンをコピーして保管(ページを離れたら戻れない)。

改めてpush

再び、ターミナルでエラーになったファイルに移動してpush!!!

$ git push origin ブランチ名
Username for 'https://github.com': ユーザー名記入
Password for 'https://ユーザー名@github.com': ここのパスワード入力部分に生成したアクセストークンを入力。

結果、push成功!!!

有効期限を設定した場合は、入力した期限まで使えて、過ぎた場合はまた生成しなければならない。

改めてわかる事があれば随時追記していきます。

参考記事

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1