Macで自分のレポジトリにpushしようとしたときに、権限がないと怒られてpushできなくなってしまいました。
$ git push origin master
git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
単純にgitlabにsshすると以下のように成功のメッセージが出て通ります。
$ ssh gitlab PTY allocation request failed on channel 0 Welcome to GitLab, @<User>!
Connection to gitlab.com closed.
解決法
ssh-add
で鍵を登録してあげると解決しました。
$ ssh-add -K /path/to/<your secret key of gitlab>
# -K: パスフレーズをkeychainに保管するオプション
# -dでkeychainから削除することも可能
Identity added: /path/to/<your secret key of gitlab> (<your mail address>)
コメント