多个ssh key 共存
多 ssh key 共存的问题会比较多的出现,比如在公司的机器上,公司的git仓库的key,和自己的github key 一般是不一样的
生成多个 key
ssh-keygen -t rsa -C “youremail@email.com” -f ~/.ssh/second
生成新的ssh key并命名为second
或者ssh-keygen -t rsa -C “youremail@email.com”
在询问时定义名称
管理多个 Key
在~/.ssh/目录下新建config文件,用于配置各个公私钥对应的主机
1 2 3 4 5 6 7 8 9 |
Host github.com // 主机名字,不能重名 HostName github.com // 主机所在域名或IP User 4013465w // 用户名称 IdentityFile ~/.ssh/id_rsa_a // 私钥路径 Host b.gitcode.com // 主机名字,不能重名 HostName github.com // 主机所在域名或IP User git // 用户名称 IdentityFile C:/Users/username/.ssh/id_rsa_b // 私钥路径 |