github和bitbucket增加publickey

环境: Win7 、Git、SecureCRT
现象:
已经通过SecureCRT生成openssh格式的公钥,同时在openshift配置内增加了public keys.
git clone时报错:Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

阅读了这篇文章后,
renatoargh的回答中得到启发:
You might have to create a config file (yeap, extension-less) under ~/.ssh/config with the following contents

Host bitbucket.org
IdentityFile ~/.ssh/id_rsa_your_bitbucket_private_key
That immediately solved my problem!

解决步骤:
1、ssh -vT myuser@myhost,debug打印出如下信息:
OpenSSH_7.3p1, OpenSSL 1.0.2k 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config

发现读取的ssh配置是Git的,修改了$GIT_HOME/etc/ssh/ssh_config文件
增加了如下内容:
Host myhost
IdentityFile C:/Users/user/.ssh/my_public_key

然后重新执行上面的ssh -vT myuser@myhost

ex:
Host github.com
IdentityFile C:/Users/user/.ssh/github

Host bitbucket.org
IdentityFile C:/Users/user/.ssh/hg

分别执行:
ssh -vT git@github.com
ssh -vT git@bitbucket.org

done!