Table of Contents
問題
環境
- Windows10
- WSL2 上の Ubuntu 22.04.3 LTS
エラー内容
WSL2 のターミナルから$ git push -u origin master
したら以下のエラーが発生した。
git@github.com: Permission denied (publickey).fatal: Could not read from remote repository
解決策
キーペアの発行
# .sshフォルダへ移動$ cd ~/.ssh
# キーペアの確認$ ls
# id_rsa id_rsa.pubがない場合は、$ ssh-keygen -t rsa# -> 質問は全部Enterでスキップ
# 公開鍵をコピーする$ cat ~/.ssh/id_rsa.pub
GitHub に公開鍵を登録
GitHub トップページ > 右上のアイコン画像 > Settings > SSH and GPG keys > New SSH key
入力項目
- Title: 適当
- Key type: Authentication Key
- Key:
id_rsa.pub
の内容
疎通確認
$ ssh -T git@github.com