每次使用Mercurial时,ssh都不会要求输入密码

Fre*_*ins 5 ssh mercurial

我是一个Mercurial新手,我刚刚开始使用它.

我在本地存储库工作,当我提交更改时,我用它hg <command> ssh://user@host/usr/www/site.com/project来推送,拉动并查看传入/传出的更改.

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

Pee*_*ger 4

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

准备好密钥后,您可以使用 ssh-agent 在每个会话中仅输入一次本地私钥密码。还有充当 ssh 代理的 GUI 工具(例如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
  ...
Run Code Online (Sandbox Code Playgroud)

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

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).
Run Code Online (Sandbox Code Playgroud)

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