git 多账户配置
之前因为很久没有使用github来托管代码了,加上公司内部搭建了gitlab服务器,所以从未没有尝试过配置不同的账户来推送更新
问题比较蛋疼的是在未推送之前,github上新建了一个仓库,然后准备clone下来。所以就临时生成了一个ssh-key(因为更换过电脑,所以重新配置了),但是clone的时候被服务器拒绝了
Cloning into 'learngit'...
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is 16:27:xxx:xxx:xxxx.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
fatal: Could not read from remote repository.
尼玛,这是怎么回事,我又重新生成了一遍ssh-key,照样报错,查看了官方的issue,用ssh -T测试了一把
ssh -T git@github.com Permission denied (publickey)
的确被拒绝了。哪里配置不对吗?
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"