How to clone Mercurial repository from remote server?

How do I clone an Mercurial repository if private key is required for SSH?

I tried following and it does not work.

[email protected]:~/foo/test$ hg clone --ssh -i ~/keys/dukeimg ssh://[email protected]/www/bar/ 
abort: /home/dukeimg/keys/dukeimg: not a Mercurial bundle


You're trying to use a ssh command line (-i) option with hg. It’s not supported. Because hg doesn’t support this option, it looks for the repository to clone at ~/keys/dukeimg.

There are three possible solutions:

  1. Use the SSH key agent.
  2. Set Mercurial to use a custom SSH command line (hgrc):

    ssh = ssh -i ~/keys/dukeimg
  3. Set the SSH client to use a public key for your host (ssh_config):

        User my-ssh-user
        IdentityFile ~/keys/dukeimg

The --ssh/-e option is meant to be used like this:

hg -e 'ssh -whatever -option' ...