如何为单个 hg 存储库设置多个 ssh 身份?

发布于 2024-10-14 13:32:15 字数 388 浏览 7 评论 0原文

我正在为我的 Mercurial 存储库使用 ssh 公钥身份验证。所以我有:

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

在我的 .hgrc 中。这工作正常,并允许我推送/拉取到经过 ssh 验证的存储库。但是,我希望能够推送/拉取到另一个需要不同身份的存储库。如何配置我的 .hgrc 文件,以便将身份绑定到特定路径。我想我想要这样的东西:

[ui]
one.prefix = someserver.com
one.ssh = ssh -i ~/.ssh/id_rsa -C
two.prefix = otherserver.com
two.ssh = ssh -i ~/.ssh/otherid_rsa -C

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 fine and allows me to push/pull to an ssh-authenticated repo. However, I want to be able to push/pull to another repo that requires a different identity. How can I configure my .hgrc file so the identity is tied to a particular path. I guess I'd want something like:

[ui]
one.prefix = someserver.com
one.ssh = ssh -i ~/.ssh/id_rsa -C
two.prefix = otherserver.com
two.ssh = ssh -i ~/.ssh/otherid_rsa -C

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

偷得浮生 2024-10-21 13:32:15

在您的 ~/.ssh/config 中,添加

Host someserver.com
IdentityFile ~/.ssh/id_rsa

Host otherserver.com
IdentityFile ~/.ssh/otherid_rsa

使用 ssh 连接到主机 someserver 的任何人(包括 hg 和交互使用) .comotherserver.com 将使用指定的身份文件。

请参阅 ssh_config对于其他选项。

In your ~/.ssh/config, add

Host someserver.com
IdentityFile ~/.ssh/id_rsa

Host otherserver.com
IdentityFile ~/.ssh/otherid_rsa

and anybody (including hg and interactive use) using ssh to connect to hosts someserver.com or otherserver.com will use the specified identity files.

See ssh_config for other options.

拧巴小姐 2024-10-21 13:32:15

您可以使用 ssh 自己的工具:ssh-agent 来完成此操作。

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

那么您根本不需要 ssh 识别 .hgrc[ui] 部分中的相关任何内容。

或者你可以这样做:

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

但是 ssh-agent 在很多方面都很有用,值得把它放在你的登录脚本中并收工。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文