gitlabにsshのpublic keyの設定したあと,cloneしようとすると以下のようなエラーがでた
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.
私の場合(/.ssh/configにHost githubと書くのは間違い)で指摘されているように,ssh configの書き方が良くなかったようです.
~/.ssh/config
を以下のように書き直すことで解決した
Host gitlab.com
User git
IdentityFile ~/.ssh/id_rsa <- your key path
TCPKeepAlive yes
IdentitiesOnly yes
おわり
おまけ
SSH Key作成コマンド
ssh-keygen -t rsa -C "hoge@example.com"
接続テスト
ssh -T git@gitlab.com -i ~/.ssh/id_rsa