通过portablegit使用github时如何使用指定的密钥? [英] How to use specified key when working with github via portablegit?

查看:176
本文介绍了通过portablegit使用github时如何使用指定的密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个ssh密钥可以与github一起工作 - 我自己和我工作的组织中的一个。
我的密钥由github gui客户端自动生成,另一个由portablegit生成。
我的.ssh文件夹看起来像:

  github_rsa< --- my key 
github_rsa.pub
id_rsa< --- org key
id_rsa.pub

当我使用portablegit它需要名称为'id_rsa'的密钥,但有时我需要使用我的密钥。我可以通过添加到你的 HOME / .ssh

a config file:

 主机wpengine 
用户git
主机名git.wpengine.com
IdentityFile〜/ .ssh / myPrivateKey

您可以根据需要添加尽可能多的'Host'条目,每个条目都有不同的 IdentityFile



请参阅针对不同github帐户的多个SSH密钥设置

  #activehacker帐户
主机github.com -activehacker
主机名github.com
用户git
IdentityFile〜 /.ssh/id_rsa_activehacker

#jexchan账户
主机github.com -jexchan
HostName github.com
用户git
IdentityFile〜/ .ssh / id_rsa_jexchan

然后,您可以使用scp语法克隆您的repo:

  git clone github.com -activehacker:activehacker / gfs.git gfs_jexchan 

(而不是 ssh://git@github.com/activehacker/gfs.git ,它不会能够引用特定的私钥并且总是会回到 id_rsa 。)


I have two ssh keys to work with github - my own and one from organisation where I'm working. My key was generated automatically by github gui client and the other one was generated by portablegit. My .ssh folder looks like:

github_rsa            <--- my key
github_rsa.pub
id_rsa                <--- org key
id_rsa.pub

When I use portablegit it takes the key with name 'id_rsa' but sometimes I need to use my key too. How can I setup default key?

解决方案

You can by adding to your HOME/.ssh a config file:

Host wpengine 
user git
hostname git.wpengine.com
IdentityFile ~/.ssh/myPrivateKey

You can add as many 'Host' entry as you want, each one with a different IdentityFile

See for instance "Multiple SSH Keys settings for different github account"

#activehacker account
Host github.com-activehacker
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_activehacker

#jexchan account
Host github.com-jexchan
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_jexchan

You can then use the scp syntax for cloning your repo:

git clone github.com-activehacker:activehacker/gfs.git gfs_jexchan

(instead of ssh://git@github.com/activehacker/gfs.git, which wouldn't be able to reference a specific private key and would always fall back to id_rsa.)

这篇关于通过portablegit使用github时如何使用指定的密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆