自分で公開したGithubリポジトリになぜかpushできない.ERROR: Permission to UrusuLambda/***.git denied to ***.

sshのキー登録とpush周りで手こずったの数年ぶりだったので、メモっておく.ただ原因不明

この症状に当たる人が少ないのか、なかなかGoogleで検索しても結果が出てこなかった….

症状

  • 自分でGithubにリポジトリを公開
  • id_rsaとは別に新しいGithub用id_rsaを用意
  • git push origin masterで以下のエラー

以下がエラー詳細.[RepositoryName]には作ったリポジトリ、[username]には自分のローカルのパソコンのusernameが入ります.

$ git push origin master

ERROR: Permission to UrusuLambda/[RepositoryName].git denied to [username].

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

たぶん解決策じゃない解決策

~/.ssh/configに以下の二行を加えると行けたけど、これ意味を調べても解決策には見えない… いか二行を加えたときに初めてid_rsaのパスワードを聞いてくるポップアップが上がった…

理由がわからない.わかる人教えて欲しい.

TCPKeepAlive yes

IdentitiesOnly yes

最終的な一連の作業内容

  1. ssh-keygen -t rsa -C “xxxxxxxxx@gmail.com”でgithub用id_rsaを作る(作ったものを以下new_id_rsa, new_id_rsa.pubとする)

  2. 作ったnew_id_rsaに対してchmod 600を行っておく.
  3. Githubのssh keysにnew_id_rsa.pubを登録
  4. .ssh/configにて以下を設定

    Host github.com

         HostName github.com

         Port 22

         IdentityFile ~/.ssh/new_id_rsa

         TCPKeepAlive yes

         IdentitiesOnly yes

  5. git config –global user.name “username”を設定

  6. git config –global user.email “xxxx@example.com”を設定
  7. git remote add origin [repository address]
  8. git push origin master

これでいけるはず…

 

About the author

コメントを残す