githubでPermission to denied to エラー
githubで仕事用アカウントとプライベートアカウントを分けて管理していたら、push時にこのエラーに苦しめられた。
git push fork master
ERROR: Permission to アカウント名1/リポジトリ名 denied to アカウント名2.
fatal: The remote end hung up unexpectedly
調べてみると、どうやら別のアカウントの公開鍵が利用されてしまってエラーになるそうだ。
そこで~/.ssh/configで各アカウントを指定する。
Host github-darekadsan1
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa1
TCPKeepAlive yes
IdentitiesOnly yes
Host github-darekasan2
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa2
TCPKeepAlive yes
IdentitiesOnly yes
cloneする時もアカウントを指定する
git clone https://darekasan@github.com/darekasan/hoge.git
これで無事pushできた。
<お世話になった参考サイト様>