开发者

Having ssh not ask for a password every time with Mercurial

I'm a Mercurial newbie and I just started to use it.

I work in local repository and when I commit changes I use hg <command> ssh://user@host/usr/www/site.com/project for pushing, pulling and see the incoming/outgoing changes.

But every time ssh ask me the password. Is there a way for remember my ssh password for this purpose? Also, how can I don't write every time the full command开发者_高级运维 (ssh://user etc etc)?


You have to setup your ssh with public keys. There are many tutorials on the web e.g. see Getting started with SSH

Once you have the keys in place you can either use ssh-agent to only enter your local private-key password once per session. There are also GUI tools that act as ssh-agent (e.g. SSHKeychain on a Mac)

Or if you have low security requirements you can also generate your key without password.

But please don't store cleartext passwords in config files.

There are two possibilities to avoid typing the url on each command:

From 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
  ...

The other possibility is using the default paths:

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).

Thats what I often use, since usually you get your working directory bay cloning from somewhere and from then on I just don't specify the url and use the default.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜