赞
踩
ssh-keygen -t rsa -C "邮箱" 生成GitHub密钥
在输入完命令之后 当看到
Enter file in which to save the key (/c/Users/aaa/.ssh/id_rsa): 的时候 在这里输入你的公钥“别名”
git config user.name “用户名”
git config user.email "邮箱"
不能加global
最最关键的一步
配置config文件
在.ssh文件下手动新建config文件
每个账号单独配置一个Host,每个Host要取一个别名,每个Host主要配置HostName和IdentityFile两个属性即可
Host的名字可以取为自己喜欢的名字,不过这个会影响git相关命令,例如:
Host mygithub 这样定义的话,命令如下,即git@后面紧跟的名字改为mygithub
git clone git@mygithub:PopFisher/AndroidRotateAnim.git
HostName 这个是真实的域名地址
IdentityFile 这里是id_rsa的地址
PreferredAuthentications 表示与服务器公钥进行匹配
User 定义用户名
config文件配置如下:
# 配置github.com
Host github.com
HostName github.com
IdentityFile C:\Users\aaa\.ssh\id_rsa_anding
PreferredAuthentications publickey
User xxx(改成你的用户名)
# 配置re
Host repo.lacesar.com
HostName repo.lacesar.com
IdentityFile C:\Users\aaa\.ssh\id_rsa
PreferredAuthentications publickey
User xxx(改成你的用户名)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。