• git本地配置多个ssh key账户


    1.生成不同的key名

    github key

    ssh-keygen -t rsa -C "example@email.com” -f ~/.ssh/github_id-rsa

    gitlab key

    ssh-keygen -t rsa -C "examlpe@企业邮箱.com” -f ~/.ssh/gitlab_id-rsa

    这样在相应的目录下~/.ssh/   (linux) ,C:Users\username.ssh  (windows),生成了两种key。

    2.给远程仓库配置添加信任ssh key

    找到gitlab_id-rsa.pub,复制其中所有内容,找到远程仓库的ssh-key管理,添加上

     

    3.配置config
    linux配置
    # gitlab
    Host gitlab.com
        HostName gitlab.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/gitlab_id-rsa
    # github
    Host github.com
        HostName github.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/github_id-rsa

    Windows配置

    # 配置github.com
    Host github.com                 
        HostName github.com
        IdentityFile C:\Users\username\.ssh\github_id-rsa
        PreferredAuthentications publickey
     
    # 配置gitlab.com
    Host gitlab.com 
        HostName gitlab.com
        IdentityFile C:\Users\username\.ssh\gitlab_id-rsa
        PreferredAuthentications publickey

    3.配置远程仓库key,测试ssh key是否通过

     在远程仓库的个人配置中,将key存入,并且使用ssh -T git@github.com,是否会按照用户名验证即可。

  • 相关阅读:
    论二级域名收集的各种姿势
    我喜欢你是寂静的-聂鲁达
    早晨充满-聂鲁达
    KALI Linux更新源
    lodash throttle和debounce
    lodash capitalize 首字母大写
    C# 格式化百分比
    c# PadLeft,PadRight用法
    对象名 XXX 无效。
    lambda 分组后的count
  • 原文地址:https://www.cnblogs.com/brokencolor/p/12194228.html
Copyright © 2020-2023  润新知