日々、勉強。

自宅の開発でトラブルになったことの解決策をメモっていきます。

Could not read from remote repository が発生 (GitHub)

githubの環境構築で苦戦した内容を記載しておきます。

 

githubで認証が通っているのに、リポジトリにcloneできない現象が発生しました。

 

<成功>

$  ssh github

$ You've successfully authenticated, but GitHub does not provide shell access.Connection to github.com closed.

 

<失敗>

$ git clone <xxxxx>

$ git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

 

失敗した原因は、秘密鍵をid_rsa_githubという名称にしていたのだが、

リポジトリは、デフォルトでid_rsaを参照しているらしい。

 

とりあえず、id_rsa_githubをコピーして見る。

$ cp ~/.ssh/id_rsa_github ~/.ssh/id_rsa

$ git clone <xxxxx>

remote: Counting objects: 30, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 30 (delta 7), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (30/30), 14.03 KiB | 4.68 MiB/s, done.
Resolving deltas: 100% (7/7), done.

 

成功した。

本来は、gitのリポジトリが参照するファイル名を変更するのが筋だろうが、とりあえずのWorkaround.