配置多个SSH-Key

作者: York_魚 | 来源:发表于2017-04-16 15:15 被阅读453次

为了安全性,个人的github和公司的gitlab需要配置不同的SSH-Key。具体如下:

  1. 切换到系统的SSH目录
cd ~/.ssh
  1. 为个人的github生成SSH-Key(若还没有)
ssh-keygen -t rsa -C "your_mail@example.com" -f github_rsa

然后,前往github添加SSH公钥。

  1. 为公司的gitlab生成SSH-Key(若还没有)

ssh-keygen -t rsa -C "your_mail@company.com" -f company_rsa


然后,前往gitlab添加SSH公钥。

4. 添加配置文件(若还没有)

``` shell
touch config
  1. 为配置文件config添加如下内容
# github.com
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa

# gitlab.company.com
Host gitlab.company.com
HostName gitlab.company.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/company_rsa
  1. 测试
ssh -T git@github.com

输出

Hi YK-Unit! You've successfully authenticated, but GitHub does not provide shell access.

以上表示成功连接到了个人的github。
然后可以用同样方式测试公司的gitlab。

相关文章

  • Git配置多个SSH-KEY

    git可以配置多个ssh-key。 生成多个ssh-key命令 添加私钥

  • Git配置多个SSH-Key & python中git的使用

    一、配置多个SSH-Key 当前电脑已设置过了一个ssh-key,终端查看已配置的SSH-Key文件 cd ~/....

  • git总结

    GitHub创建远程仓库 配置多个SSH-key 当公司gitlab和自己的github都要配置ssh-key时,...

  • 配置多个SSH-Key

    为了安全性,个人的github和公司的gitlab需要配置不同的SSH-Key。具体如下: 切换到系统的SSH目录...

  • Github使用笔记

    一、配置Github环境 安装Git 配置ssh-key 检查ssh-key的设置 生成新ssh-key 添加ss...

  • Git配置多个SSH-Key

    有时候我们要管理多个git项目,或同时在用gitlab、github、小程序的tgit。当我们给一个项目配置了SS...

  • git配置多个ssh-key

    我们在日常工作中会遇到公司有个gitlab,还有些自己的一些项目放在github上,这样就导致我们要配置不同的ss...

  • git配置多个ssh-key

    在公司上班项目是push到公司自己搭的gitlab,平时自己的项目是push到github。他们分别使用的是不同的...

  • git配置多个SSH-Key

    我们在日常工作中会遇到公司有个gitlab,还有些自己的一些项目放在github上。这样就导致我们要配置不同的ss...

  • Git配置多个SSH-Key

    背景 当有多个git账号时,比如: a. 一个gitee,用于公司内部的工作开发;b. 一个github,用于自己...

网友评论

    本文标题:配置多个SSH-Key

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