gitのアカウントで設定しているメールアドレスに以下の通知が来た。
Hi @[アカウント名]
You recently used a password to access the repository at kazudetatsumi/ktpro with git using git/2.17.1.
Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.
Thanks,
The GitHub Team
言われうままにリンク先をみると、2021年8月にパスワードを打ち込んでのヤリトリを停止するとのこと。パスワードを使ってヤリトリしてきたユーザーは、ssh認証またはトークンでの認証にしなさいと
のこと。トークン認証では1年間ヤリトリがなかったものは停止してしまうとのこと。
以上のことから、先人の記述を参考にssh認証をできるように試みた。
1. 鍵の作成
ssh-keygen -t rsa -b 4096 -C "[アカウント名]@github.com"
-C 以下は識別用のコメント。
-b 4096 で鍵の長さが長くなり、安全性うぷ。
すでにある公開鍵と区別するために、$HOME/.ssh/id_rsa_githubという鍵の名前で保存。
パスフレーズは空欄ではなく入力する。
2. gitのホームページにログインし、sshの鍵を登録する。
3. .ssh/configの記述
Host github
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
4.eval "$(ssh-agent -s)" でssh-agentが動いていることを確認し、
ssh-add $HOME/.ssh/id_rsa_github
で鍵をssh-agentに追加。このとき1で設定したパスフレーズを入力。
5. ssh -T git@github.com 以下のレスポンスが帰ってきたらおK.
Hi [アカウント名] ! You've successfully authenticated, but GitHub does not provide shell access.
git remote set-url origin github:[アカウント名]/[プロジェクト名].git
追記(2021/09/09)
異なる計算機からssh接続する場合、.ssh/id_rsa_githubをrsyncした上で、3.以降を行う。
追記(2021/11/18)
ssl-vpnでほかの計算機につなげている場合,githubへの通信はできない.