配置多平台SSH-Key

进入零碎ssh目录

cd ~/.ssh

生成github密钥

ssh-keygen -t rsa -C "your_mail@example.com" -f github_rsa

回车确认,直到实现。其余账号操作相似

生成gitlab密钥

ssh-keygen -t rsa -C "your_mail@example.com" -f gitlab_rsa

生成gitee密钥

ssh-keygen -t rsa -C "your_mail@example.com" -f gitee_rsa

查看公钥

// 查看github公钥cat github_rsa.pub// 查看gitlab公钥cat gitlab_rsa.pub// 查看gitee公钥cat github_rsa.pub

将失去的公钥别离复制到对应账号SSH设置中

增加config文件(若无)

touch config //mac linux,windows举荐应用git bash

为config文件增加如下内容

# github.comHost github.comHostName github.comPreferredAuthentications publickeyIdentityFile ~/.ssh/github_rsa# gitlab.company.comHost gitlab.company.com # 此域名端口默认22,如果为122端口,需设置gitlab.company.com:122HostName gitlab.company.comPreferredAuthentications publickeyIdentityFile ~/.ssh/gitlab_rsa# gitee.comHost gitee.comHostName gitee.comPreferredAuthentications publickeyIdentityFile ~/.ssh/gitee_rsa

测试

// test github ssh-keyssh -T git@github.com// test gitlab ssh-keyssh -T git@gitlab.company.com// test gitee ssh-keyssh -T git@gitee.com

胜利

输入内容如下时,配置胜利

Hi YK-Unit! You've successfully authenticated, but GitHub does not provide shell access.

此输入内容为测试github ssh-key,其余账号测试内容相似

揭示

Windows系统命令终端举荐应用git bash。