栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

git操作之一台mac电脑绑定两个git账号,用于工作和学习区分

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

git操作之一台mac电脑绑定两个git账号,用于工作和学习区分

1、查看已有密钥
$ cd ~/.ssh
$ ls


可以看到有id_rsa.pub和id_rsa这1对密钥了

2、生成新的密钥
ssh-keygen -t rsa -f ~/.ssh/id_rsa_2 -C "yourmail@xxx.com"

输入命令后会出现让你输密码,可以直接回车,此时输入命令ls就可以看到多出现了一对id_rsa_study.pub和id_rsa_study密钥了

3、在github账户中添加公钥

点击头像➡️Settings➡️SSH and GPG keys➡️SSH Keys➡️New SSH key

可以执行open id_rsa_study.pub打开该文件进行复制

4、配置.ssh/config将不同的账户区分
$ touch ~/.ssh/config
$ open config

直接打开config文件作为文档进行编辑

#Default GitHub
Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
#Study GitHub
Host study.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_study
5、确定是否连上github
$ssh -T git@study.github.com

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/457109.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号