赞
踩
目前多个项目的需求,需要一台mac本支持多个git的服务器,因此需要生成多个ssh的key,配置。
1 ssh-keygen -t rsa -C "email@mail.com"
2 Enter file in which to save the key (/Users/用户/.ssh/id_rsa):
添加需要存储地方的名字如果之前没有存储key键值的信息则可以直接填写:Users/用户/.ssh/id_rsa
如果之前生成过了Users/用户/.ssh/id_rsa的key键值,则可以换一个其他的名字Users/用户/.ssh/id_rsa_xx
3 ssh-add ~/.ssh/id_rsa_xx 添加之前生成key键值
4 vim ~/.ssh/config 打开了config的文件,对key键值进行配置
配置多个key键值的内容:
#code.hualai.com
Host xx
User xx
HostName xx
Port xx
identityfile ~/.ssh/id_rsa
#github.com
Host github.com
HostName github.com
User xx@mail.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
5 vim ~/.ssh/id_rsa.pub 或者vim ~/.ssh/id_rsa_github.pub 打开pub文件copy key文件
6 复制key文件到github ssh的key上面
ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB1hVvAF8cKfyplc362wDFLmmIh0dJD23RawhwqyUTKYvREjK203MCdaMqMYKOlhVBIFe5l0UCjOfVtiby9wj2F2rdy+b9zTFECEOuRHcQrwvBGdyVxbJccWkoBp xx@mail.com
7 输入:wq 退出vim
8 输入命令 ssh git@github.com,测试是否建立成功
9 显示You've successfully authenticated即建立成功了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。