git 配置多个SSH keys
来源:互联网 发布:安徽秉知装饰有限公司 编辑:程序博客网 时间:2024/04/27 21:48
背景
工作中公司用到了gitlab,而个人开发一些项目/工程使用的是github
配置
一般第一个SSH Keys大家都知道怎么配置,所以这里就不说第一个的配置了,主要是讲讲如何配置第二个。
步骤
生成一个自定义用的SSH-Key(这里我生成github的)
$ ssh-keygen -t rsa -C "youremail@your.com” -f ~/.ssh/github-rsa
在~/.ssh/目录会生成github-rsa和github-rsa.pub私钥和公钥。 我们将github-rsa.pub中的内容粘帖到github服务器的SSH-key的配置中(利用命令 cat gitbub-rsa-pub 打开)
添加私钥
$ ssh-add ~/.ssh/github_rsa
如果执行ssh-add时提示”Could not open a connection to your authentication agent”,可以现执行命令:
$ ssh-agent bash
然后再运行ssh-add命令。
可以通过 ssh-add -l 来确私钥列表
$ ssh-add -l
可以通过 ssh-add -D 来清空私钥列表
$ ssh-add -D
修改配置文件
在 ~/.ssh 目录下新建一个config文件
touch config
添加内容
添加操作:用 vi file.name 打开文件,输入,然后按 esc键,输入:wq保存退出。
#gitlabHost gitlab.com HostName gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa#githubHost github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github_rsa
测试
$ ssh -T git@github.com
输出
Hi stefzhlg! You’ve successfully authenticated, but GitHub does not provide shell access.
就表示成功的连上github了.也可以试试链接公司的gitlab.
阅读全文
0 0
- git 配置多个SSH keys
- 【git】SSH keys 生成,管理多个 SSH keys ,代码第一次提交到远程仓库
- git 配置多个ssh
- Windows Git SSH keys:
- GitHub账户设置多个SSH Keys
- 配置SSH Keys到github,实现git clone 能力
- gitHub 配置SSH Keys
- Git多个ssh key配置
- Git配置多个SSH-Key
- git ssh 配置多个账户
- git 配置多个SSH-Key
- git如何配置多个ssh-key
- git 配置多个SSH-Key
- Git配置多个SSH Key
- mac下git配置多个ssh
- git 配置多个SSH-Key
- Git配置多个SSH-Key
- Generating SSH Keys fro git
- mysql修改numberic类型自动转换成decimal
- Navicat把excel表格数据导入数据库表
- Leetcode Distinct Subsequences
- PAT (Advanced Level) Practise 1094 The Largest Generation (25)
- gitlab如何导入已经存在(存在于另外的gitlab)的项目
- git 配置多个SSH keys
- Xib文件 Cell中添加滚动视图 UIScrollView
- Bpmn和xml文件相互转化
- Centos任务栏不见了
- js中的__proto__和prototype
- PAT甲级 1008. Elevator (20)
- 4.4以上BaseActivity 设置状态栏背景
- mysql数据库中java的long转成时间
- 集成百度地图定位时初学者遇到的一些小坑