Git配置ssh秘钥

修改时间: 2020-06-6 13:23:00 PM

文章时间:2020年6月6日 13:12:07
解决问题:Git配置ssh秘钥
基于系统:windows、linux

一、Windows平台

生成SSH Key

ssh-keygen -t rsa -C "sun@hcses.com"

注:sun@hcses.com 替换为你自己的邮箱,生成时一路下一步即可

查看SSH Key

type %userprofile%\.ssh\id_rsa.pub

二、Linux平台

生成SSH Key

ssh-keygen -t rsa -C "sun@hcses.com"

查看SSH Key

cat ~/.ssh/id_rsa.pub

三、将生成的秘钥填入平台

chrome_tapSIXnjRW.png

四、生成多套ssh秘钥

在日常使用中,可能会出现拥有多个平台的账号的情况。例如:github、gitee、私有git等

Windows版本生成命令

ssh-keygen -t rsa -C 'admin@hcses.com' -f %userprofile%/.ssh/github_id_rsa
type %userprofile%\.ssh\github_id_rsa.pub

Linux版本生成命令

ssh-keygen -t rsa -C 'admin@hcses.com' -f ~/.ssh/gihub_id_rsa
cat ~/.ssh/gihub_id_rsa.pub

注:需要修改的为邮箱和最后的ssh秘钥名称,替换为不同的名称即可

添加新评论