カテゴリー
【GitHubよもやま話】GitHubへのアクセスをパーソナルアクセストークン方式にお引越しさせてみた
※ 当ページには【広告/PR】を含む場合があります。
2021/07/29
2024/01/10

$ git pull origin main
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
fatal: unable to access 'https://github.com/**********/**************.git/': The requested URL returned error: 403
Mid-2021 – Personal access or OAuth tokens will be required for all authenticated Git operations.
GitHubのパーソナルアクセストークンを新規発行する
[Settings] > [Developer settings] > [Personal access tokens]

[Generate new token]

Custom


repo
admin:repo_hook
delete_repo
[Generate token]


gitコマンドで再認証作業
$ git config --global --unset credential.helper
$ git clone https://github.com/************/**********.git
Cloning into '***************'...
Username for 'https://github.com': [ユーザー名]
Password for 'https://ユーザー@github.com': [パーソナルアクセストークン]
git config credential.helper store

トークンの有効期限が切れた後のパーソナルアクセストークン再設定
$ git clone https://github.com/***************/*************.git
Cloning into '*************'...
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 pull origin main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
hint: Pulling without specifying how to reconcile divergent branches is
#...省略
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com//**********/*********.git/'
$ git push origin main
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/***************.git/'
リモート管理者側のアクセストークン再発行作業
[Settings] > [Developer settings] > [Personal access tokens]

[Delete]


repo
admin:repo_hook
read:org
delete_repo

ユーザー側のgit環境周りの更新作業
local
global
system
[local] > [global] > [system]
git config --list
global
$ git config --global --list
credential.https://github.com.helper=
credential.https://github.com.helper=!/home/linuxbrew/.linuxbrew/Cellar/gh/2.32.1/bin/gh auth git-credential
credential.https://gist.github.com.helper=
credential.https://gist.github.com.helper=!/home/linuxbrew/.linuxbrew/Cellar/gh/2.32.1/bin/gh auth git-credential
user.email=t*************************p
user.name=**************
credential.helper=store
credential.helper=store
#👇パスワードをグローバル(ユーザー全体)で使っている場合
$ git config --global --unset credential.helper
#👇パスワードをローカル(対象リポジトリのみ)で使っている場合
$ git config --local --unset credential.helper
#👇パスワードをシステム(gitコマンド共有)で使っている場合
$ git config --system --unset credential.helper
$ git clone https://github.com/***********/***********.git
Cloning into '***********'...
Username for 'https://github.com': ***********
Password for 'https://***********@github.com':
remote: Enumerating objects: 76, done.
remote: Counting objects: 100% (76/76), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 76 (delta 33), reused 57 (delta 19), pack-reused 0
Unpacking objects: 100% (76/76), done.
$ git config [--global/--local/--system] credential.helper store
$ git config --global --unset-all user.name
$ git config --global --unset-all user.email
#👇リストでユーザー名・emailが消えているかを確認
$ git config --global --list
credential.https://github.com.helper=
credential.https://github.com.helper=!/home/linuxbrew/.linuxbrew/Cellar/gh/2.32.1/bin/gh auth git-credential
credential.https://gist.github.com.helper=
credential.https://gist.github.com.helper=!/home/linuxbrew/.linuxbrew/Cellar/gh/2.32.1/bin/gh auth git-credential
GitHubアカウントへ2段階認証(2FA)を追加する

[Enable 2FA]

[Confirm]

1Password
Authy
[Verify the code from the app]

[Download]
[I have saved my recoverry codes]

Passkeys
参考サイト
記事を書いた人
ナンデモ系エンジニア
主にAngularでフロントエンド開発することが多いです。 開発環境はLinuxメインで進めているので、シェルコマンドも多用しております。 コツコツとプログラミングするのが好きな人間です。
カテゴリー