paranitips

Never stop learning! がモットーのゆるふわエンジニアブログ

git pushで「Permission denied (publickey).」を解決する

gitでGitHubにあるリポジトリにpushしようとしたらエラーが出ました。

% git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

サーバーとの接続を確認する

% ssh -vT git@github.com
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/hoge/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
...
...
Hi 49hacker! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2736, received 3000 bytes, in 0.5 seconds
Bytes per second: sent 5173.3, received 5672.4
debug1: Exit status 1

公開鍵がgithubアカウントに紐付けられているか確認する

% ssh-add -l
2048 b2:f4:0d:bd:8f:03:fe:ad:4b:0d:55:e5:7b:63:44:95 /Users/hoge/.ssh/id_rsa (RSA)

詳しくはGitHub Helpによくまとまっています。

参考