Git多个SSH Key共存解决方案

目前手上不止一个git账号,平台也不一致,这就比较尴尬了:

  1. 同一个SSH Key中不允许两个账号
  2. 再次生成新的SSH Key会将上次的覆盖

目前的解决办法是,生成多个SSH Key并命别名,通过配置文件指定域

用ssh-keygen生成多个key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ ssh-keygen -t rsa -C "wuwz@live.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/wuwenze/.ssh/id_rsa): /Users/wuwenze/.ssh/github
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa_github.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa_github.pub.
The key fingerprint is:
SHA256:T4s5hxOOX3ABGNHZNMPX6v7J1rgYxfzXMCuCipIh5Ng wuwz@live.com
The key's randomart image is:
+---[RSA 2048]----+
| o=.=+ . |
| . o.oo. . |
| .. . |
| . ..o |
|+. S o. * |
|o.E o @ ... =.|
| . o . O *.o .o+|
| o . o = ..=o.o|
| .. . . .o=. |
+----[SHA256]-----+

根据提示,重新指定文件名,假设我有三个平台需要同时管理,即

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×