多个sshkey 指定key来clone仓库
Something like this should work (suggested by orip):
ssh-agent bash -c 'ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git'
if you prefer subshells, you could try the following (though it is more fragile):
ssh-agent $(ssh-add /somewhere/yourkey; git clone git@github.com:user/project.git)
Git will invoke SSH which will find its agent by environment variable; this will, in turn, have the key loaded.
Alternatively, setting HOME may also do the trick, provided you are willing to setup a directory that contains only a .ssh directory as HOME; this may either contain an identity.pub, or a config file setting IdentityFile.
None of these solutions worked for me.
Instead, I elaborate on @Martin v. Löwis 's mention of setting a config file for SSH.
SSH will look for the user's ~/.ssh/config file. I have mine setup as:
Host gitserv
Hostname remote.server.com
IdentityFile ~/.ssh/id_rsa.github
IdentitiesOnly yes # see NOTES below
And I add a remote git repository:
git remote add origin git@gitserv:myrepo.git
And then git commands work normally for me.
git push -v origin master
NOTES
- The
IdentitiesOnly yesis required to prevent the SSH default behavior of sending the identity file matching the default filename for each protocol. If you have a file named~/.ssh/id_rsathat will get tried BEFORE your~/.ssh/id_rsa.githubwithout this option.
References
多个sshkey 指定key来clone仓库的更多相关文章
- GitHub设置使用SSH Key,用TortoiseGit进行Clone仓库
GitHub设置使用SSH Key的好处就是可以使用SSH连接,并且提交代码的时候可以不用输入密码,免密提交. 生成SSH Key 这里我们使用PuTTYgen来生成公钥(Public Key),私钥 ...
- 高效率遍历Map以及在循环过程中移除 remove指定key
//高效率遍历Map以及在循环过程中移除 remove指定key //使用iter循环的时候 可以在循环中移除key,for在循环的过程中移除会报错哦 //本方法效率高 Iterator iter = ...
- 如何从二维数组中的多个key中获取指定key的值?
精华 LOVEME96 2016-10-21 10:40:19 浏览(1512) 回答(3) 赞(0) 新手求教:二维数组中一般会有多个key,如果我们要获得指定key的值,应该怎么做? 问题标签: ...
- 在Maven项目中,指定使用阿里云仓库下载jar包
Maven项目中,在pom.xml的</project>标签之前加入一下标签,指定使用阿里云仓库下载jar包. <!-- 使用aliyun maven --> <repo ...
- C++ map修改指定key的value
对于修改C++指定key的value,网上查了很多,都说直接insert就会覆盖原来的值,是否是这样的呢? C++ Code 12345678910111213141516171819202122 ...
- hadoop 指定 key value分隔符
原文:http://wingmzy.iteye.com/blog/1260570 hadoop中的map-reduce是处理<key,value>这样的键值对,故指定<key,val ...
- git clone 仓库的部分代码
对于较大的代码仓库来说,如果只是想查看和学习其中部分源代码,选择性地下载部分路径中的代码就显得很实用了,这样可以节省大量等待时间. 比如像 Chromium 这种,仓库大小好几 G 的. clone ...
- Flink 自定义source和sink,获取kafka的key,输出指定key
--------20190905更新------- 沙雕了,可以用 JSONKeyValueDeserializationSchema,接收ObjectNode的数据,如果有key,会放在Objec ...
- git -C <other-git-repo-path> [git-command] 指定其它路径的仓库 执行命令
git -C <other-git-repo-path> [git-command] 指定其它路径的仓库 执行命令 注意,-C 要在命令之前 例如: git -C d:/testRepo ...
随机推荐
- 20170622xlVBA多部门分类汇总同类合并单元格
Public Sub Basic_CodeFrame() AppSettings On Error GoTo ErrHandler Dim StartTime, UsedTime As Variant ...
- SQL 进阶视频课程。Udacity: Intro to Relational Databases和 PostgreSQL语法文档。
Udacity: Intro to Relational Databases The syntax of the select statement with a where clause: selec ...
- 『科学计算』可视化二元正态分布&3D科学可视化实战
二元正态分布可视化本体 由于近来一直再看kaggle的入门书(sklearn入门手册的感觉233),感觉对机器学习的理解加深了不少(实际上就只是调包能力加强了),联想到假期在python科学计算上也算 ...
- ccf画图
问题描述 在一个定义了直角坐标系的纸上,画一个(x1,y1)到(x2,y2)的矩形指将横坐标范围从x1到x2,纵坐标范围从y1到y2之间的区域涂上颜色. 下图给出了一个画了两个矩形的例子.第一个矩形是 ...
- OA项目(MVC项目)
1. 新建,项目,其他项目类型,空白解决方案 2. 选中解决方案,添加,新建项目,类库: (1)添加OA.Model,删除其中的Class1.cs (2)添加OA.DAL(数据访问层),删除Class ...
- EBS 快速创建供应商的标准创建逻辑
该页面经过了客户化,只保留了这三个字段. 点击应用时执行 oracle.apps.pos.supplier.webui.SuppCrtCO String s29 = (String)((OAAppli ...
- OC NSArray数组排序
一.一般排序 // 排序 NSArray *arr = @["]; NSArray *newarr = [arr sortedArrayUsingSelector:@selector(com ...
- C++技能重拾2
13.类成员函数重载:局部同名函数将隐藏而不是重载全局声明,不引入父类名字空间时子类的同名函数不会和父类的构成重载,静态成员函数可以和非静态成员函数构成重载.本质是重载函数的定义是在相同的声明域里!! ...
- splunk 通过rest http导入数据
使用 HTTP Event Collector go to Settings > Data inputs > HTTP Event Collector. Then click the Gl ...
- JavaScript学习总结(六)——JavaScript判断数据类型总结
最近做项目中遇到了一些关于javascript数据类型的判断处理,上网找了一下资料,并且亲自验证了各种数据类型的判断,在此做一个总结吧! 一.JS中的数据类型 1.数值型(Number):包括整数.浮 ...