git 多帐户配置

以前由于好久没有使用github来托管代码了,加上公司内部搭建了gitlab服务器,因此从未没有尝试过配置不一样的帐户来推送更新git

问题比较蛋疼的是在未推送以前,github上新建了一个仓库,而后准备clone下来。因此就临时生成了一个ssh-key(由于更换过电脑,因此从新配置了),可是clone的时候被服务器拒绝了github

Cloning into 'learngit'...shell

The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established.服务器

RSA key fingerprint is 16:27:xxx:xxx:xxxx.ssh

Are you sure you want to continue connecting (yes/no)? ide

Host key verification failed.gitlab

fatal: Could not read from remote repository.测试

尼玛,这是怎么回事,我又从新生成了一遍ssh-key,照样报错,查看了官方的issue,用ssh -T测试了一把google

ssh -T git@github.com
Permission denied (publickey)

的确被拒绝了。哪里配置不对吗?spa

OMG,没有配置仓库的gitconfig?好,那我配置!尼玛,依然被拒绝了。肿么回事,干净百度/google下

擦!原来要针对github的访问作一个配置。。ok

vi ~/.ssh/config
// 粘贴一下内容
Host github.com
    User git
    Port 22
    IdentityFile ~/.ssh/id_rsa_github

ok! 妥妥的。再测试一把

bird-mac:bird$ test bird-jarvis$ ssh -T git@github.com
Hi bird! You've successfully authenticated, but GitHub does not provide shell access.

个人公钥:ssh-keygen -t rsa -f id_rsa_github -C "key for github"

相关文章
相关标签/搜索