1,执行命令,生产公钥、私钥。
ssh-keygen -t ed25519 -C "email@example.com"
或者
ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
以上两种是根据不同加密生成的公、私钥。
2,生成结果如下
如果已经生成过秘钥,在想保留原先秘钥基础上再创建一个新的秘钥,可以在此处修改所创建的秘钥的位置和名字,并作出如下配置即可使用。
新建config文件,并配置如下
Host gitlab.com
HostName gitlab.com
IdentityFile C:\Users\yiyueqinghui.ssh\id_ed25519
其中Host,HostName是添加秘钥网站的域名,IdentityFile是对应秘钥的地址
如果想要添加多个,可以如下配置
Host gitlab.com
HostName gitlab.com
IdentityFile C:\Users\yiyueqinghui.ssh\id_ed25519Host github.com
HostName github.com
IdentityFile C:\Users\yiyueqinghui.ssh\github.com
3,再将公钥配置到相应的gitlab、github位置即可