How to setup multiple ssh identities for single hg repository?

前端 未结 2 1934
北恋
北恋 2021-02-10 02:54

I am using ssh publickey authentication for my mercurial repository. So I have:

[ui]
ssh = ssh -i ~/.ssh/id_rsa -C 

in my .hgrc. This works f

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-10 03:05

    You do it using ssh's own tool: ssh-agent.

    $ eval $(ssh-agent)
    $ ssh-add ~/.ssh/id_rsa
    $ ssh-add ~/.ssh/otherid_rsa
    

    Then you don't need ssh identify related anything in your .hgrc's [ui] section at all.

    Alternately you could do:

    [ui]
    ssh = ssh -i ~/.ssh/id_rsa -i ~/.ssh/otherid_rsa -C
    

    but ssh-agent is useful in so many way's it's worth putting it your login scripts and calling it a day.

提交回复
热议问题