views:

55

answers:

2

Hi guys, I use mercurial in my project, and every time I push new changesets to the server by ssh, it ask me for a password.
Then how to config the mercurial to push with out asking password?

I works on Ubuntu 9.10

+3  A: 
OJ
+7  A: 

On Linux and Mac, use ssh-agent.

  1. Ensure you have an ssh keypair (see man ssh-keygen for details)
  2. Copy your public key (from ~/.ssh/id_dsa.pub) to the remote machine, giving it a unique name (such as myhost_key.pub)
  3. Log in to the remote machine normally and append the public key you just copied to the ~/.ssh/authorized_keys file
  4. Run ssh-add on your local workstation to add your key to the keychain

You can now use any remote hg commands in this session without requiring authentication.

gavinb
What should I do on the new 'myhost_key.pub' on the server side? I just copy it to ~/.ssh/ dir, and touched a new file called 'authorized_keys'. and then added one line in it:'myhost_key.pub'. But it dosen't work;
Croplio
You need to append the contents of the public key to the `authorized_keys` file, not just put a reference to it. The reason the instructions don't say to copy it to that name directly is to not overwrite its existing contents. So step 2 gets the key onto the remote host, and step 3 is to put its contents into the correct file. After that, you can delete the copied `myhost_key.pub`. I hope that clarifies things.
gavinb
It works now,really thank you, gavinb!
Croplio