Github 多账号配置

1. 不同账户,生成不同密钥
ssh-keygen -t rsa -f github1 -C "[email protected]"
ssh-keygen -t rsa -f github2 -C "[email protected]"

2. 把生成的公钥添加到github上,设置,ssh-key,new ssh。

3. 编辑~/.ssh/config文件添加如下内容:
  # 其中Host是主机别名,HostName是github服务器地址,User是GitHub服务器用户名,
  # IdentityFile是和GitHub服务器通信的ssh私钥,通过IdentityFile就可以区分出
  # 不同的账号。
  Host account1
  HostName github.com
  User git
  IdentityFile ~/.ssh/github1
  Host account2
  HostName github.com  
  User git
  IdentityFile ~/.ssh/github2
4. ssh-add 管理
  ssh-add github1
  ssh-add github2

5. git remote set-url origin account1:github账号/xxxx.git

猜你喜欢

转载自www.cnblogs.com/hanwen1014/p/10386209.html