让一个客户端支持多个git账户

2017-4-11 liyangweb.com 李杨 Web周边

1.在客户端中生成第一个ssh密钥,下面的邮箱地址,需替换成自己的邮箱(如已经生成过,此步骤忽略)

ssh-keygen -t rsa -C "aaa@163.com"

系统会提示输入密钥的保存路径以及密码,这里我们保持默认,一路回车。

2.查看public key

cat ~/.ssh/id_rsa.pub

3.将密钥添加到你的git服务器(github、git.oschina、coding等)的my ssh处。

至此第一个ssh密钥生成并添加成功,下面我们来添加第二个git密钥

4.在客户端再次生成一个ssh密钥,下面的邮箱地址,替换成自己的另一个邮箱


ssh-keygen -t rsa -C "bbb@163.com"

5.系统会做出如下提示,如果我们敲回车,将会提示是否覆盖,我们要两个ssh密钥生效,自然不允许覆盖,所以这里我们不能直接回车

Enter file in which to save the key (/Users/liyang/.ssh/id_rsa):

6.这里我们给id_rsa重新定义一个名字id_rsa_2,密码依旧默认(默认为空)

Enter file in which to save the key (/Users/liyang/.ssh/id_rsa):/Users/liyang/.ssh/id_rsa_2

7.查看public key

cat ~/.ssh/id_rsa_2.pub

8.将密钥添加到你的git服务器(github、git.oschina、coding等)的my ssh处。

9.但是默认情况下,系统只会去找命名为id_rsa的key,要支持第二个key,就要额外设置一下了,我们在~/.ssh文件夹下打开或创建config文件

vim config

10.在此文件中输入以下配置,具体内容根据实际环境修改。


Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa

Host github2
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_2

 其规则就是:从上至下读取config的内容,在每个Host下寻找对应的私钥。这里将GitHub SSH仓库地址中的git@github.com替换成新建的Host别名如:github2,那么原地址是:git@github.com:xxx/xxx.git,替换后应该是:git@github2:xxx/xxx.git.



标签: git

评论:

intoloo
2019-02-09 13:31
<a href="http://www.mikespothole.com/nike-sportswear-sky-force-88-vintage-1-zapatosu">nike sportswear sky force 88 vintage 1</a> <a href="http://www.theclaydoctor.com/adidas-porsche-design-911s-brun-gr%C3%B8nn-chaussuresa">adidas porsche design 911s brun gr酶nn</a> <a href="http://www.allthatspool.com/limited-ryan-clady-youth-jersey-denver-broncos-78-home-orange-nflf">limited ryan clady youth jersey denver broncos 78 home orange</a> <a href="http://www.ihavewed.com/air-jordan-1-pinnacle-white-light-runningg">air jordan 1 pinnacle white light</a> <a href="http://www.cloudsmartin.com/nfl-pittsburgh-steelers-color-rush-limited-antonio-brown-mens-football-jersey-nflv">nfl pittsburgh steelers color rush limited antonio brown mens football jersey</a> <a href="http://www.myachingoa.com/air-jordan-6-toro-inferred-jordan-shoe-trainersa">air jordan 6 toro inferred jordan shoe</a>
intoloo http://www.intoloo.com/
isampled
2019-02-05 17:49
<a href="http://www.lagunawoodsre.com/mens-nike-free-tr-fit-all-purple-shoesi">mens nike free tr fit all purple</a> <a href="http://www.highbacklink.com/nike-roshe-run-speckle-herre-bl%C3%A5-skoj">nike roshe run speckle herre bl氓</a> <a href="http://www.vuurogen.com/free-run-2-all-hvit-obuvi">free run 2 all hvit</a> <a href="http://www.rsvppersonnel.com/kvinners-nike-lebron-13-gr%C3%A5-bl%C3%A5-obuvp">kvinners nike lebron 13 gr氓 bl氓</a> <a href="http://www.shonema.com/kvinners-air-max-90-em-gr%C3%B8nn-bl%C3%A5-obuvi">kvinners air max 90 em gr酶nn bl氓</a> <a href="http://www.enventsurvey.com/mujeres-asics-gel-noosa-tri-10-blanco-zapatosp">mujeres asics gel noosa tri 10 blanco</a>
isampled http://www.isampled.com/
cruelvamp
2019-01-05 08:19
<a href="http://www.imdesignr.tw/parajumper-v%C3%A5rjakke-parajumpersr">parajumper v氓rjakke</a> <a href="http://www.rhizomelic.tw/burberry-tie-box-tier">burberry tie box</a> <a href="http://www.dealsilike.tw/how-much-is-a-moncler-vest-monclerr">how much is a moncler vest</a> <a href="http://www.lizrollins.tw/prada-sunglasses-canada-pradar">prada sunglasses canada</a> <a href="http://www.gtldsales.tw/james-johnson-new-jersey-nflr">james johnson new jersey</a> <a href="http://www.byebybaby.tw/nobis-jacket-online-nobisr">nobis jacket online</a>
cruelvamp http://www.cruelvamp.tw/
risaralda
2019-01-04 22:37
<a href="http://www.impulsodigital.net/adidas-pr%C3%B8dator-line-king-obuve">adidas pr酶dator line king</a> <a href="http://www.industrialamps.net/adidas-tubular-runner-r%C3%B8d-lyser%C3%B8d-obuve">adidas tubular runner r酶d lyser酶d</a> <a href="http://www.jifivillage.net/nike-free-run-2-ext-sort-lyser%C3%B8d-trainers-name-kurpesd">nike free run 2 ext sort lyser酶d trainers name</a> <a href="http://www.jolkona.net/nike-lunarglide-5-prize-blu-schuhee">nike lunarglide 5 prize blu</a> <a href="http://www.justadrink.net/nike-lebron-soldier-10-sort-gr%C3%B8n-kurpesf">nike lebron soldier 10 sort gr酶n</a> <a href="http://www.kouder.net/nike-cortez-unisexe-noir-obuva">nike cortez unisexe noir</a>
risaralda http://www.risaralda.net/
erickasouza
2019-01-04 02:34
<a href="http://www.betascgx.com/mackage-bags-australia-day-2017-mackaged">mackage bags australia day 2017</a> <a href="http://www.hobbyfreaks.com/tory-burch-tote-bag-sale-toryburchr">tory burch tote bag sale</a> <a href="http://www.ruoiled.com/adidas-adizero-f50-trx-herre-gr%C3%B8n-runninga">adidas adizero f50 trx herre gr酶n</a> <a href="http://www.zanascuisine.com/mackage-high-neck-leather-jacket-mackager">mackage high neck leather jacket</a> <a href="http://www.puyichinese.com/michael-kors-crossbody-studded-mini-selma-price-mke">michael kors crossbody studded mini selma price</a> <a href="http://www.philipelara.com/moncler-coat-womens-red-leggings-price-monclerg">moncler coat womens red leggings price</a>
erickasouza http://www.erickasouza.com/
btmtecled
2019-01-01 17:24
<a href="http://www.acforlessllc.com/nike-air-max-1-r%C3%B8d-october-kurpesc">nike air max 1 r酶d october</a> <a href="http://www.thehodostore.com/ray-ban-clubmaster-51-nz-sunglassesc">ray ban clubmaster 51 nz</a> <a href="http://www.gandoff.com/mens-nike-new-york-jets-19-keyshawn-johnson-limited-green-player-name-number-tank-top-nfl-jersey-nflr">mens nike new york jets 19 keyshawn johnson limited green player name number tank top nfl jersey</a> <a href="http://www.langbenlang.com/adidas-predator-absolion-trx-turf-skoa">adidas predator absolion trx turf</a> <a href="http://www.glennloovens.com/air-max-90-black-and-white-oreo-sneakerf">air max 90 black and white oreo</a> <a href="http://www.kamilotomotiv.com/nike-shox-turbo-21-cielo-azul-rosado-kurpesa">nike shox turbo 21 cielo azul rosado</a>
btmtecled http://www.btmtecled.com/
infoility
2018-12-28 19:32
<a href="http://www.redstonecloud.com/air-jordan-11-retro-low-brosso-acquistare-butya">air jordan 11 retro low brosso acquistare</a> <a href="http://www.thepoolfloats.com/nike-roshe-run-hombres-blanco-z06-schuheg">nike roshe run hombres blanco z06</a> <a href="http://www.tsgctt.com/womens-ralph-lauren-city-polo-orange-green-poloz">womens ralph lauren city polo orange green</a> <a href="http://www.virginiaflyin.com/jordan-retro-3-wolf-gris-chaussuresa">jordan retro 3 wolf gris</a> <a href="http://www.bandbwhitby.com/nike-air-force-1-low-nero-and-bianca-suede-schuhee">nike air force 1 low nero and bianca suede</a> <a href="http://www.funkymediamx.com/jordan-retro-13-squadron-bl%C3%A5-toddler-scarpea">jordan retro 13 squadron bl氓 toddler</a>
[url=http://www.infoility.com/]infoility[/url]
byvestella
2018-12-27 11:55
<a href="http://www.sigaldavid.com/nike-kobe-11-mujeres-rosado-negro-obuvc">nike kobe 11 mujeres rosado negro</a> <a href="http://www.souvkaretbdg.com/asics-gel-noosa-tri-9-l%C3%B8ping-sko-kvinners-scarpea">asics gel noosa tri 9 l酶ping sko kvinners</a> <a href="http://www.busancitynews.com/jordan-retro-8-bugs-bunny-sort-chaussuresg">jordan retro 8 bugs bunny sort</a> <a href="http://www.cigarlogbook.com/kvinders-nike-air-max-2017-gr%C3%B8n-orange-kurpese">kvinders nike air max 2017 gr酶n orange</a> <a href="http://www.dineet.com/nike-lunarglide-6-silber-gelb-obuva">nike lunarglide 6 silber gelb</a> <a href="http://www.glamlustlife.com/polo-ralph-lauren-custom-fit-big-pony-polo-shirt-in-gelb-polox">polo ralph lauren custom fit big pony polo shirt in gelb</a>
byvestella http://www.byvestella.com/

发表评论:

Powered by emlog 冀ICP备13011830号-1