美文网首页
mac 一台电脑两个github账号

mac 一台电脑两个github账号

作者: 页面仔小杨 | 来源:发表于2017-09-01 16:26 被阅读0次

mac 一台电脑两个github账号

自己有两个github账号,要配置在同一台笔记本上

个人账号:itxingOne@163.com

公司账号:itxingTwo@163.com

假设个人账号已经配置,现在添加公司账号itxingTwo@163.com

1.配置账号

$ git config --global user.name "itxingTwo"

$ git config --global user.email "itxingTwo@163.com"

2.生成ssh密钥

$ ssh-keygen -t rsa -C "itxingTwo@163.com"

3.设置名称为id_rsa_two(名称随意)

$ Enter file in which to save the key (/Users/Administrator/.ssh/id_rsa): id_rsa_two

4.新密钥添加到SSH agent中

$ ssh-agent bash

$ ssh-add ~/.ssh/id_rsa_two

5.创建一个config文件,必须先进入ssh目录下创建

$ cd ~/.ssh

$ touch config

6.在config中配置你使用的git

Host github.com

  HostName github.com

  IdentityFile ~/.ssh/id_rsa

Host github_two

  HostName github.com

  IdentityFile ~/.ssh/id_rsa_two

7.将id_rsa_two.pub中的内容添加到gitlab帐号下的SSH Key中

8.添加SSH Key后进行测试是否连接成功

$ ssh -T github.com

成功则

Welcome to Git@xxxx, yourname!

失败则

Permission denied (publickey).

解决方案

$ ssh-add ~/.ssh/id_rsa_two

一切风平浪静,努力学习吧

相关文章

网友评论

      本文标题:mac 一台电脑两个github账号

      本文链接:https://www.haomeiwen.com/subject/ngckjxtx.html