0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHubのパスワード認証エラーの原因と解決方法まとめ

Posted at

事象

git push を実行してローカルの変更を GitHub 上のリモートリポジトリへ push しようとしたところ、以下のようなエラーが発生しました。

$ git push
Username for 'https://github.com': john.smith@example.com
Password for 'https://john.smith@example.com@github.com':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/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/john.smith/hello-world.git/'

原因

2021年8月13日以降、GitHub ではセキュリティ強化の一環として、HTTPS 経由での Git 操作において、GitHub アカウントのパスワードによる認証が廃止されました。これにより、従来のようにパスワードを入力して push することができなくなっています。

解決方法

現在推奨されている認証方法はいくつかありますが、私が実際に利用したことのある方法を3つ紹介します。

1. GitHub CLIを利用する

GitHub CLIを使えば、ターミナル上で簡単に認証を行うことができます。

  1. GitHub CLIをインストールする
  2. 認証を作業を行う
    • gh auth login

2. GitHub Desktopを利用する

ターミナル操作にこだわりがなければ、GitHub Desktopを使うのも簡単です。GUIで直感的に操作できます。インストール後に GitHub アカウントでログインすれば、push や pull などの操作もシームレスに行えます。

3. PATを利用する

パスワードの代わりに、Personal Access Token(PAT)を使って認証する方法です。セキュリティ上、トークンの管理に注意が必要ですが、最も直接的な方法でもあります。

  1. GitHubの開発者設定からPersonal Access Tokenを発行する
  2. git push時にパスワードの代わりに発行したトークンを入力する

環境

  • git version 2.43.0.windows.1
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?