久しぶりにGitHubからクローンを取得しようとしたらエラーになったので、クローン方法のおさらいをします。
git cloneでエラーになった
2021年8月13日以降にユーザ名、パスワードのみでは取得できなくなりました。
41d924eac70f:/var/test# git clone https://github.com/yuyami-jp/schedule.git
Cloning into 'schedule'...
Username for 'https://github.com': yuyami-jp
Password for 'https://yuyami-jp@github.com':
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/yuyami-jp/schedule.git/'
参考:https://qiita.com/ynaito/items/9171d13f21210da9a5c3
git clone方法
トークンを使用することでクローン取得ができるようになるようです。
トークンの発行
・トークン設定ページに遷移
Setting > Developer settings > Personal access tokens > Tokens (classic)



・Genenate new token (classic)をクリック

・ログイン

・払い出し期間と権限を設定し「Generate token」ボタンをクリック
Noteの入力をしないとはじかれてしまったので適当に入力してください。(トークンを識別する名前みたいなものです)

・トークンが払い出される(1度しか表示されないのでコードをコピーしてください)

git cloneの実行
クローンコマンドを実行します。
パスワードを入力する箇所にトークンを入力します。
41d924eac70f:/var/test# git clone https://github.com/yuyami-jp/schedule.git
Cloning into 'schedule'...
Username for 'https://github.com': yuyami-jp
Password for 'https://yuyami-jp@github.com': [トークンを入力]
最後に
トークン方式に変更することでパスワード漏洩リスクが減るし、アクセス権限や期間を細かく設定できるようになるのはいいことですね。
少し面倒だけど期間を切って運用していこうと思います。