• mac上面配置多个不同仓库的SSH Key


    同一台电脑会连接不同的远端仓库,github/gitlab等,就需要生成不同的SSH Key对应多个远端仓库。

    这里只说明在mac上的操作。

    1、进入~/.ssh目录下

    cd ~/.ssh

    2、生成SSH Key

    ssh-keygen -t rsa -C "your_name@email_name.com"  // 后面的邮箱是你需要链接的远端仓库的账号邮箱

    然后我们会看到如下信息,输入key的名字,不输入的话默认名字是id_ras

    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/beibei/.ssh/id_rsa): 

    一路回车键,会生成id_rsa和id_rsa.pub 2个key

    重复这一步,新建一个名字,如id_ras_company,
    得到id_rsa_company和id_rsa_company.pub 2个key

    其中id_rsa是私钥 id_rsa.pub是公钥

    3、执行下面的命令,将生成的key添加

    ssh-add id_rsa

    4、去github上面添加配置

    id_rsa.pub里面的内容复制下来,在github上的settings里面找到add keys,将其粘贴到key即可,title随便填

    5、输入配置文件

    进入~/.ssh目录, 创建一个config文件,然后配置参数

    cd ~/.ssh
    vim config

    输入格式如下:

    #github
    Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    #gitee
    Host gitee.com
    HostName gitee.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    #company
    Host git_company_url.com
    HostName git_company_url.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_company

    6、验证

    ssh -T git@github.com
    ssh -T git@gitee.com
    ssh -T git@git_company_url.com

    输出

  • 相关阅读:
    摘记
    【题解】网格 & Single Cut of Failure(trick:答案上界)
    题解 CF1404C 【Fixed Point Removal】
    Linux IO模型知识梳理
    Java IO模型知识梳理
    如何回答什么是线程安全?
    MySQL主从复制与备份
    MySQL的高性能索引策略
    CAS(乐观锁)的原理解析
    Java虚拟机的类加载机制
  • 原文地址:https://www.cnblogs.com/DI-DIAO/p/12576657.html
Copyright © 2020-2023  润新知