赞
踩
背景:在工作中,都会有一个工作的Git帐号(公司Gitlab),而空闲时间做的个人东西又想放进Github里面,这时候就需要配置两个帐号和服务器。假设之前已经配置好了工作的帐号,打开Git bash:
[html] view plain copy
因为默认只读取id_rsa,为了让SSH识别新的私钥,需将其添加到SSH agent中:
[html] view plain copy
注意:如果出现Could not open a connection to your authentication agent,参考底部详情
若~/.ssh/目录下不存在config文件,则新建一个,内容写上:
[html] view plain copy
把~/.ssh/id_rsa_hason.pub的内容添加到Github的SSH keys中
使用ssh -T git@Host进行测试,其中Host指上面配置的服务器别名
[html] view plain copy
常见问题:
1、出现Could not open a connection to your authentication agent
3种解决方法:
(a) 先输入ssh-agent bash,然后再输入ssh-add ~/.ssh/id_rsa_hason;
(b)先输入eval $(ssh-agent),然后输入ssh-add ~/.ssh/id_rsa_hason;
(c)使用Git GUI生成密钥,密钥会自动被加进ssh-agent中;
阿里云学生机1年114元限时活动(24岁以下都可以购买)https://promotion.aliyun.com/ntms/act/campus2018.html?userCode=a6violqw阿里云1888元红包:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=a6violqw
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。