git cloneではまった

git cloneではまりました。。。
bitbucketを利用して、クローンしていたのですがhttpsからsshに切り替えようとしてました。
すると、

# git clone git@bitbucket.org:xxxxxxxxx/yyyyyyy.git
Cloning into 'yyyyyyy'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

が出ていた。。。
~/.ssh/config内の設定も問題無さそうだったし、
bitbucket側へも公開鍵の登録も問題無さそうだった。




解決策としてはこちらが参考になった。(公式ドキュメントを読みましょう。。。)
ja.confluence.atlassian.com

# ssh-add -l
Could not open a connection to your authentication agent.
root@ip-10-10-4-180 ~ 
# ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
root@ip-10-10-4-180 ~ 


ssh-addできなかった。。という事で下記の記事を参考に
qiita.com

root@ip-10-10-4-180 ~ 
# eval `ssh-agent`
Agent pid 17584
root@ip-10-10-4-180 ~ 
# ssh-add ~/.ssh/id_rsa
Identity added: /home/ubuntu/.ssh/id_rsa (/home/ubuntu/.ssh/id_rsa)
root@ip-10-10-4-180 ~ 

最後にクローンして終了

root@ip-10-10-4-180 ~ 
# git clone git@bitbucket.org:xxxxxxxx/yyyyyyy.git
Cloning into 'yyyyyyy'...
remote: Counting objects: 5375, done.
remote: Compressing objects: 100% (2381/2381), done.
remote: Total 5375 (delta 4051), reused 3966 (delta 2936)
Receiving objects: 100% (5375/5375), 9.85 MiB | 328.00 KiB/s, done.
Resolving deltas: 100% (4051/4051), done.
root@ip-10-10-4-180 ~ 


結局SSH側の問題だったのですね。
大分はまりました。