/.ssh/config gitlab


gitlabにsshのpublic keyの設定したあと,cloneしようとすると以下のようなエラーがでた

[email protected]: 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 "[email protected]"

接続テスト

ssh -T [email protected] -i ~/.ssh/id_rsa