[[Home|» Project Kenai Documentation and Training]] [[Howdoi|» How Do I ...]] [[Usinghg-win|» Using Mercurial on Microsoft Windows Systems]] <h1>Setting Up Mercurial to Use SSH on a Microsoft Windows Machine</h1> Before reading this section, make sure you've installed the Mercurial client. As described at [[SourceControl#About_Mercurial|About Mercurial]], you can download the Mercurial client as an installable binary from [http://www.selenic.com/mercurial/wiki/index.cgi]. Use the default settings and ensure that the installer adds the Mercurial path to the system PATH environment variable. In addition, these instructions assume that you've generated an SSH key with PuTTY as described at [[Winsshwithputty|Generating and Using an SSH Key on a Microsoft Windows Machine]]. '''Note:''' Thanks to Oliver Reeves (OJ) for his blog [http://buffered.io/2009/05/16/setting-up-trac-mercurial-and-ssh-on-windows Setting up Trac, Mercurial, and SSH on Windows], which was very helpful in writing this page. To use an SSH key with Mercurial that you've generated with PuTTY tools, you need to configure Mercurial to use the PuTTY tools when using SSH. The Mercurial configuration file you'll use to do this is typically called <tt>.hgrc</tt>. On Windows it can also be called <tt>Mercurial.ini</tt>. The file is located in your home folder, for example, <tt>C:/Documents and Settings/your-username</tt>. If you don’t know where your home folder is, open a Command window and type <tt>echo</tt> <tt>%USERPROFILE%</tt> to see the path. If you haven’t set up your Mercurial configuration yet, chances are the configuration file doesn’t exist, and you’ll have to create it. Create a file call either <tt>.hgrc</tt> or <tt>Mercurial.ini</tt> in your home folder and open it in a text editor. For example, in Cygwin, you could create the file with the following command: ~ cat > .hgrc Type Ctrl-C to close the file and save it, and then you can reopen it in Notepad to edit it. Here is what the ssh lines in the file would look like: <nowiki>[ui]</nowiki> ssh = plink -ssh -i "C:/path/to/key/id_rsa.ppk" -C -agent This line tells Mercurial to use the <tt>plink</tt> program. This program comes with PuTTY and is a command-line version of what the PuTTY program does behind the scenes. Here's what the parameters mean: * <tt>-ssh</tt>: Indicates that Mercurial should use the SSH protocol. * <tt>-i “file.ppk”</tt>: Specifies the location of the private key file you want to use to log in to the remote server. Change this to point to your local putty-compatible <tt>.ppk</tt> private key. Make sure to use forward slashes for the path separators. * <tt>-C</tt>: Enable compression. * <tt>-agent</tt>: This tells plink to talk to the pageant utility to get the passphrase for the key instead of asking you for it interactively. You're now ready to use Mercurial with SSH.