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
最終的な一連の作業内容
-
ssh-keygen -t rsa -C “xxxxxxxxx@gmail.com”でgithub用id_rsaを作る(作ったものを以下new_id_rsa, new_id_rsa.pubとする)
- 作ったnew_id_rsaに対してchmod 600を行っておく.
- Githubのssh keysにnew_id_rsa.pubを登録
- .ssh/configにて以下を設定
Host github.com
HostName github.com
Port 22
IdentityFile ~/.ssh/new_id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
-
git config –global user.name “username”を設定
- git config –global user.email “xxxx@example.com”を設定
- git remote add origin [repository address]
- git push origin master
これでいけるはず…