FaqHgSSH

How do I set up SSH with Mercurial?

Mercurial with the ssh:// access method type is one of the protocols supported in NetBeans that calls for valid settings in the mercurial config file. This file is located at:

  • Windows systems: %USERPROFILE%\Mercurial.ini or <mercurial_installation_directory>\Mercurial.ini
  • Unix systems, including Macintosh: $HOME/.hgrc>

Open this file and edit the ui section:

  • Windows:
# with the use of private key authentication
ssh = plink.exe -l <username> -i D:/new_my_private_key.ppk 
# or with password authentication
ssh = plink.exe -l <username> -pw password

Putty applications can be downloaded as binaries from the following page: http://www.chiark.greenend.org.uk/sgtatham/putty/download.html

  • Unix-like systems:
ssh = ssh -l <username> -i identy_file

SSH password-caching tools can help if SSH is repeatedly asking for the password. SSH password-caching tools include Pageant (as a part of Putty applications) on Windows and ssh-agent on Unix-like systems. If a key was generated along with the PassPhrase, you have to use the "ssh password-caching" tool.

  • Windows:
    1. Modify the ui section of the Mercurial.ini file:
      ssh = plink -l <username>
    2. Download and start the Pageant tool. (It is displayed in the system tray).
    3. Open it and add the key. You will be prompted for the PassPhrase.
  • Unix-like systems:
    1. Modify the ui section of the ~/.hgrc file: //
      ssh = ssh -l <username>
    2. Run
      ssh-agent in terminal
      . This will print variables that should be set and exported (SSH_AUTH_SOCK, SSH_AGENT_PID).
    3. Export all variables generated by the ssh-agent.
    4. Run
      ssh-add /path_to_indentity_file
    5. Start NetBeans IDE from the same terminal.


Tunneling SSH through a Proxy:

This section describes how to tunnel through an http-proxy server without any server-side modifications.

  • Windows:
    1. Start Putty application.
    2. Select the Connection | Proxy item. Set required Proxy type and fill Proxy hostname, Port. (If the proxy server asks for authentication, fill in a valid Username and Password)
    3. Now select Session item again and enter the session name into Saved Sessions field. (session name must match the hostname of the mercurial repository. For example: for the Repository URL https://peterp.org/hgrepo the session name has to be peterp.org)
    4. Save the session.
  • Unix-like systems:
    1. Download and extract corkscrew.
    2. In the corkscrew directory type: ./configure, make and make install
    3. Add a new line to your ~/.ssh/config
#relplace the http proxy and port settings with the correct values
ProxyCommand /usr/local/bin/corkscrew proxy.example.com 8080 %h %p
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo