多个ssh_key的生成与使用
Last updated
Last updated
git config --global user.name "Your Name"
git config --global user.email "Your Email Address"
ssh-keygen -t rsa -C "Your Email Address"
Ps.ssh-keygen -t rsa -C "13683265113@163.com"
ssh-keygen -t rsa -C “Your Email Address” -f 'Your Name'
Ps.ssh-keygen -t rsa -C “gaotianyang@haomo-studio.com” -f 'gaotianyangHM'
(此时会在.ssh下生成gaotianyangHM & gaotianyangHM.pub)
ssh-keygen -t rsa -C "Your Email Address"
Enter file in which to save the key (/c/Users/Lenovo/.ssh/id_rsa):'Your Name'
Ps.Enter file in which to save the key (/c/Users/Lenovo/.ssh/id_rsa):'gaotianyangHM'
(此时同样会在.ssh下生成gaotianyangHM & gaotianyangHM.pub)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host my.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/my
Ps.Host名字随意,接下来会用到
ssh -T git@github.com
测试结果失败,未成功添加处理办法:
刷新新添加的ssh
ssh-add -l
重启电脑(待测试)
如下两种解决方法:
打开.Git/config文件
#更改[remote "origin"]项中的url中的
#my.github.com 对应上面配置的host
[remote "origin"]
url = git@my.github.com:itmyline/blog.git
或者在Git Bash中提交的时候修改remote
$ git remote rm origin
$ git remote add origin git@my.github.com:itmyline/blog.git
#my.github.com对应一个账号
git clone git@my.github.com:username/repo.git
Ps.git clone git@HM.github.com:username/repo.git
Ps.git clone git@gtyHM.github.com:username/repo.git
ssh -T git@gaotianyangHM.github.com
Ps.如果出现Hi xxx!You've successfully authenticated 就说明连接成功了