在实际的工作中,

有可能需要连接多个远程仓库,

例如我想连接私有仓库、GitLab官网、GitHub官网,

那么同一台电脑就要生成多个ssh key;

ssh-keygen -t rsa -C "526861348@qq.com"

第2、3个私钥分别命名为:

id_rsa_gitlab与id_rsa_github,

密码为空

添加密钥到SSH Agent,

因为默认只读取id_rsa

在C:\Users\Administrator\.ssh目录下创建config文件(不要后缀):

# 配置私有仓库
Host MyGitLab              
    HostName 192.168.1.105
    IdentityFile C:\Users\Administrator\.ssh\id_rsa
    PreferredAuthentications publickey
    User yangjianliang
    
# 配置gitlab官网
Host gitlab.com
    HostName gitlab.com
    IdentityFile C:\Users\Administrator\.ssh\id_rsa_gitlab
    PreferredAuthentications publickey
    User yangjianliang
    
# 配置github官网
Host github.com                 
    HostName github.com
    IdentityFile C:\Users\Administrator\.ssh\id_rsa_github
    PreferredAuthentications publickey
    User yangjianliang

分别去几个仓库填入公钥:

测试连接

ssh -T git@192.168.1.105

ssh -T git@gitlab.com

ssh -T git@github.com

会在C:\Users\Administrator\.ssh目录下生成known_hosts文件

此时,

C:\Users\Administrator\.ssh目录会有以下文件:

git clone git@gitlab.com:yjlch1016/SP_API.git

拉某个项目

Git生成多个ssh key的更多相关文章

  1. 「BUAA OO Pre」Git生成多个ssh key并连接GitLab仓库

    「BUAA OO Pre」Git生成多个ssh key并连接GitLab仓库 Part 0 前言 写作背景 笔者在配置学校GitLab的ssh key时遇到一些问题,原因应为曾经配置过GitHub的s ...

  2. git生成并添加SSH key

    1.安装Git Bash https://git-scm.com/downloads 2.鼠标右键git bash here 3.执行以下命令: ①   cd ~/.ssh/    [如果没有对应的文 ...

  3. git 生成并添加 SSH key

    git config --global user.name "wangjunqiang" git config --global user.email "wangjunq ...

  4. Git安装以及配置SSH Key——Windows

    安装 安装 Git 官网下载一个Windows版本的Git. 然后一直下一步即可,如下图 环境变量自动配好的,可以去检查一下环境变量中PATH中有没有Git的环境变量 然后在桌面右击鼠标,选择Git ...

  5. Jenkins配置git/github 插件的ssh key

    参考来源:http://jingyan.baidu.com/article/a65957f4f0acc624e67f9bc1.html 方式一:本地需要生成公私钥文件,git/github中新建ssh ...

  6. oschina git服务, 如何生成并部署ssh key

    1.如何生成ssh公钥 你可以按如下命令来生成 sshkey: ssh-keygen -t rsa -C "xxxxx@xxxxx.com" # Generating public ...

  7. Git使用之设置SSH Key

    设置SSH Key 1.    检查是否已经有SSH Key. $cd ~/.ssh 如果说没有这个目录,就直接看第三步 2.    备份 3.    生成一个新的SSH. $ssh-keygen - ...

  8. GitHub使用笔记1:git客户端配置多ssh key

    公司用gitlab 外网的github同时配置 这样就导致我们要配置不同的ssh-key对应不同的环境. 具体操作步骤如下: 1:生成一个公司用的SSH-Key $ ssh-keygen -t rsa ...

  9. 生成并部署SSH key

    1.如何生成ssh公钥 你可以按如下命令来生成 sshkey: ssh-keygen -t rsa -C "xxxxx@xxxxx.com" # Generating public ...

随机推荐

  1. Spring(三)之Ioc、Bean、Scope讲解

    Spring容器是Spring Framework的核心.容器将创建对象,将它们连接在一起,配置它们,并管理从创建到销毁的整个生命周期.Spring容器使用DI来管理组成应用程序的组件.这些对象称为S ...

  2. [转]TortoiseSVN客户端的安装

    TortoiseSVN是windows平台下Subversion的免费开源客户端. 一般我们都是先讲讲服务器的配置,然后再讲客户端的使用,但是在TortoiseSVN上,却可以反过来.因为,如果你的要 ...

  3. HDU 2307 贪心之活动安排问题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2037 今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)  ...

  4. 怎样卸载wineQQ?

    好久没实用ubuntu系统的wineqq了.今天用的时候,提示无法使用,要求官网又一次下载新版本号,  感觉挺麻烦的,准备卸载,半天卸载不了. 经过努力,终于还是卸载了. 卸载命令: sudo dpk ...

  5. 【MySQL】基本语句

    ##mac启动mysql的命令语句## /usr/local/mysql/bin/mysql -u root -p ##然后输入密码 查看当前存在数据库 show databases; 创建数据库 c ...

  6. 留言板(初学者使用js实现)

    代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  7. poj1733 Parity Game(扩展域并查集)

    描述 Now and then you play the following game with your friend. Your friend writes down a sequence con ...

  8. #leetcode刷题之路21-合并两个有序链表

    将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例:输入:1->2->4, 1->3->4输出:1->1->2-&g ...

  9. MySQL->索引的维护[20180504]

    学习MySQL数据库中表的索引维护(新增和删除)       索引的好处:             提高查询的效率             可限定特定的资料(如唯一)     索引的不足:       ...

  10. laravel5.5源码笔记(六、中间件)

    laravel中的中间件作为一个请求与响应的过滤器,主要分为两个功能. 1.在请求到达控制器层之前进行拦截与过滤,只有通过验证的请求才能到达controller层 2.或者是在controller中运 ...