多个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 ...
随机推荐
- 缓存地图 ArcGIS ——Local compact and exploded tile cache layer for WPF API
ArcGISArcGIS 主页 特色 合约 图库 地图 组 帮助 我的内容 我的组织 登录 我的个人资料 帮助 管理员指南 登出 0 搜索全部内容 搜索地图 搜索图层 搜索应用程序 搜索工具 搜索 ...
- 问题✅:render json的格式支持。to_json被改成as_json,功能一样
class StudentsController < ApplicationController def show @student = Student.find(params[:id]) re ...
- codeforces 853b//Jury Meeting// Codeforces Round #433 (Div. 1)
题意:几个人要去一个城市k天,现给出各航班的日期和花费,让这n个人能相会k天的最小花费? 用数组arr1[i]记录在第i天人到齐的最小花费.arr2[i]记录第i天之后才有人开始走的最小花费.然后取a ...
- Ciel the Commander CodeForces - 321C (树, 思维)
链接 大意: 给定n结点树, 求构造一种染色方案, 使得每个点颜色在[A,Z], 且端点同色的链中至少存在一点颜色大于端点 (A为最大颜色) 直接点分治即可, 因为最坏可以涂$2^{26}-1$个节点 ...
- pluck的返回值
前言 今天用到了laravel的pluck功能,就顺便记录下来. pluck是获取所读取的数据一列或者两列的方法. 一.获取一列代码如下: ->pluck('pic_url') ; 结果如下: ...
- python-day21--os模块
os模块是与操作系统交互的一个接口''' os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作 ...
- hpu积分赛(回溯法)
问题 : 不开心的小明① 时间限制: 1 Sec 内存限制: 128 MB 提交: 2 解决: 1 题目描述 一天, 小明很不开心,先是向女神表白被拒, 数学又考了0分, 回家的路上又丢了钥匙, 他非 ...
- PHP:第一章——按位运算和求余运算(判断奇偶数)
<?php //按位运算:与1按位运算等于0,输出偶数.如果等于1,输出奇数 //输出偶数: for($i=0;$i<10;$i++){ if(($i & 1)==0){ echo ...
- [转载]JS浏览器兼容性问题
from:http://dada-fangfang.iteye.com/blog/811749 做BS开发就难免会用到javascript,而每个浏览器对javascript的支持有不同.这就需要我们 ...
- nested exception is java.sql.SQLException: Incorrect string value: '\xE7\x99\xBB\xE9\x99\x86...' for column 'image' at row 1
HTTP Status 500 - Hibernate operation: could not insert: [cn.itcast.shop.product.vo.Product]; uncate ...