1

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

I tried following and it does not work.

dukeimg@localhost:~/foo/test$ hg clone --ssh -i ~/keys/dukeimg ssh://username@example.com/www/bar/ 
abort: /home/dukeimg/keys/dukeimg: not a Mercurial bundle
  • 1
    And how exactly does it not work? Please provide all output. – Daniel B Jun 29 '16 at 12:24
3

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

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

    Host example.com
        User my-ssh-user
        IdentityFile ~/keys/dukeimg
    

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

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.