【问题标题】:Having ssh not ask for a password every time with Mercurial每次使用 Mercurial 时,ssh 都不会要求输入密码
【发布时间】:2011-05-25 04:59:32
【问题描述】:

我是 Mercurial 新手,刚开始使用它。

我在本地存储库中工作,当我提交更改时,我使用hg <command> ssh://user@host/usr/www/site.com/project 进行推送、拉取和查看传入/传出的更改。

但是每次ssh都问我密码。有没有办法为此目的记住我的 ssh 密码?另外,我怎么能不每次都写完整的命令(ssh://user 等)?

【问题讨论】:

  • 你使用的是什么操作系统?
  • Mac OS X 和服务器运行 Debian。
  • 关于您的最后一个问题,请参阅 .hg/hgrc 文件中的 [paths] 部分。

标签: mercurial ssh


【解决方案1】:

您必须使用公钥设置您的 ssh。网上有很多教程,例如见Getting started with SSH

一旦你有了密钥,你可以使用 ssh-agent 在每个会话中只输入一次本地私钥密码。还有一些 GUI 工具充当 ssh-agent(例如,Mac 上的 SSHKeychain

或者,如果您的安全要求不高,您也可以在没有密码的情况下生成密钥。

但请不要在配置文件中存储明文密码。

避免在每个命令上输入 url 有两种可能性:

来自hg help urls

These URLs can all be stored in your hgrc with path aliases under the
[paths] section like so:

  [paths]
  alias1 = URL1
  alias2 = URL2
  ...

另一种可能性是使用默认路径:

default:
  When you create a repository with hg clone, the clone command saves the
  location of the source repository as the new repository's 'default'
  path. This is then used when you omit path from push- and pull-like
  commands (including incoming and outgoing).

这是我经常使用的,因为通常你会从某个地方克隆你的工作目录,从那时起我只是不指定 url 并使用默认值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 2022-01-25
    • 2016-08-25
    • 2013-07-22
    • 2021-03-29
    • 2021-11-24
    相关资源
    最近更新 更多