Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having ssh not ask for a password every time with Mercurial

Tags:

ssh

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

like image 329
Fred Collins Avatar asked Oct 11 '22 22:10

Fred Collins


1 Answers

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.

like image 185
Peer Stritzinger Avatar answered Jan 22 '23 14:01

Peer Stritzinger