Programming

Store password in TortoiseHg

27 September 2026 · 7 min read

Store password in TortoiseHg

Managing version control effectively often involves frequent interactions with remote repositories. For users of TortoiseHg, a popular graphical front-end for the Mercurial distributed version control system, repeatedly entering credentials for every push or pull operation can become tedious and disruptive to workflow. Fortunately, TortoiseHg offers several mechanisms to securely store password in TortoiseHg, streamlining your development process without compromising security. This guide will delve into the various methods available, their underlying principles, and best practices to ensure your credentials remain protected while enjoying a smoother version control experience. Understanding these options is crucial for any developer aiming to optimize their daily interactions with Mercurial repositories, especially when working on projects hosted remotely.

Why Store Passwords in TortoiseHg? Enhancing Workflow and Security

The primary reason developers opt to store passwords in TortoiseHg is to eliminate the repetitive manual entry of credentials. Imagine performing dozens of commits, pushes, and pulls throughout a single workday; each requiring you to type out a complex password. This not only consumes valuable time but also introduces friction into an otherwise fluid development cycle. By caching or securely storing these details, TortoiseHg allows for seamless, uninterrupted interaction with remote repositories, significantly boosting productivity.

Beyond convenience, secure password storage can also enhance overall security. When you repeatedly type passwords, there’s a higher risk of them being observed (shoulder surfing) or intercepted by keyloggers if your system is compromised. Utilizing built-in, encrypted storage solutions within TortoiseHg or leveraging system-level security features like SSH agents or operating system keyrings minimizes exposure. These methods are designed to protect your sensitive authentication details, making them less vulnerable than manual entry. Implementing a robust strategy to store password in TortoiseHg is a key aspect of maintaining an efficient and secure development environment.

Furthermore, for teams working on collaborative projects, consistent authentication practices are vital. Standardizing how credentials are managed across team members using TortoiseHg can prevent access issues and ensure everyone can seamlessly interact with the shared repository. This contributes to a more cohesive and productive development ecosystem. According to a study by Forrester, inefficient processes, including repeated authentication, can lead to significant productivity losses in software development teams.

Methods to Store Password in TortoiseHg: HTTP/HTTPS and SSH

TortoiseHg supports different protocols for interacting with remote repositories, primarily HTTP/HTTPS and SSH. Each protocol offers distinct ways to manage and store password in TortoiseHg, catering to various security requirements and infrastructure setups.

HTTP/HTTPS Authentication

For repositories accessed via HTTP or HTTPS, TortoiseHg can be configured to cache passwords or utilize an external credential helper. The simplest method involves letting TortoiseHg remember your password for a session. When you first connect to a repository that requires authentication, TortoiseHg will prompt you for your username and password. There’s often an option to “Remember password” or “Save credentials.” If you select this, TortoiseHg will store the password, usually encrypted, in its configuration or a system-specific credential store.

For example, on Windows, TortoiseHg often integrates with the Windows Credential Manager. This means your passwords are encrypted and managed by the operating system’s secure storage, providing a centralized and robust way to handle multiple credentials. This approach ensures that even if your Mercurial configuration files are accessed, the passwords themselves are not directly readable. This is often the most straightforward way for users to store password in TortoiseHg when using HTTP/HTTPS.

SSH Authentication with PuTTY/Pageant

For repositories accessed via SSH, the process is slightly different and often more secure, especially for automated processes or environments requiring higher security. SSH authentication typically relies on public-key cryptography, where you generate a pair of keys: a private key (kept secret) and a public key (shared with the server). Instead of a password, your private key authenticates you.

TortoiseHg, on Windows, often integrates seamlessly with PuTTY and its companion, Pageant (the PuTTY authentication agent). Pageant allows you to load your private SSH key (which can be passphrase-protected) once per session. Once loaded into Pageant, any SSH client (including TortoiseHg via its internal Mercurial client) can use this key for authentication without requiring you to re-enter the passphrase for each connection. This is an extremely efficient and secure way to manage SSH credentials and is highly recommended for developers who frequently interact with SSH-based Mercurial repositories. To effectively store password in TortoiseHg via SSH, understanding Pageant’s role is key.

To use this method:

  1. Generate an SSH key pair using PuTTYgen, saving your private key (e.g., as a .ppk file) and associating it with a strong passphrase.
  2. Load your private key into Pageant. You’ll be prompted for the passphrase once.
  3. Ensure TortoiseHg is configured to use PuTTY for SSH connections (this is often the default on Windows installations).
  4. When TortoiseHg attempts an SSH connection, it will automatically look for loaded keys in Pageant, authenticating without further password prompts.

This method drastically improves workflow for SSH users, making it a preferred choice for many professionals. You can find more detailed instructions on setting up SSH keys with PuTTY on the SSH.com website.

Advanced Configuration and Best Practices for Password Storage

While the default options for storing passwords are convenient, understanding advanced configurations and best practices can further enhance both security and usability. This includes managing credentials via the .hgrc file and understanding the implications of different storage methods.

For more granular control, you can sometimes specify credentials directly in your Mercurial configuration file, .hgrc (located in your user profile directory or the repository’s .hg folder). While direct password entry in .hgrc is generally discouraged due to security risks (passwords are stored in plain text), it’s possible to specify credential helper programs or define user-specific authentication sections. For example, you might configure specific aliases for repositories that automatically use certain stored credentials or SSH keys without exposing the password itself in the configuration file. This level of customization allows experienced users to fine-tune how TortoiseHg handles authentication.

A crucial best practice is to always use strong, unique passphrases for your SSH private keys and complex passwords for HTTP/HTTPS authentication. Even if stored securely, a weak credential remains a potential vulnerability. Regularly rotating your passwords and keys, especially after any security incident, is also advisable. For further security insights, consulting resources like the NIST Digital Identity Guidelines can provide robust recommendations for password management and authentication.

When you store password in TortoiseHg, consider the environment. On shared machines, avoid saving credentials. For personal development machines, leveraging OS-level keyring services (like Windows Credential Manager or macOS Keychain) is generally the most secure and convenient approach, as these are designed to protect sensitive data at the operating system level.

Infographic here: A visual flowchart outlining the decision process for choosing between HTTP/HTTPS password caching and SSH agent-based authentication, highlighting pros and cons of each.
Troubleshooting Common Password Storage Issues in TortoiseHg ------------------------------------------------------------

Even with robust mechanisms to store password in TortoiseHg, users occasionally encounter issues. Understanding common problems and their solutions can save significant time and frustration. One frequent issue is an “authentication failed” error, even when credentials are believed to be correctly stored. This could stem from several factors: a changed password on the remote server that hasn’t been updated locally, an expired SSH key, or a corrupted credential cache.

If you suspect a cached password is incorrect, clearing the cached credentials is often the first step. For HTTP/HTTPS, this typically involves going to the TortoiseHg settings or, on Windows, directly managing credentials via the Control Panel’s Credential Manager. Search for entries related to your repository’s URL and delete them. The next time you connect, TortoiseHg will prompt you for new credentials, allowing you to re-enter the correct ones and choose to save them again. For SSH issues, ensure Page Question & Answer :

Is there a way to configure TortoiseHg to store my password?

I have a project hosted on Google Code that I access using TortoiseHg. Whenever I want to push changes to Google Code TortoiseHg prompts me for a username and password. Google Code requires me to use an auto-generated password, and it gets quite repetitive to look it up every time.

Both existing answers suggest storing your username and password unencrypted in plain-text, which is a bit of a no-no.

You should use the Keyring extension instead, as it has been specifically designed for securely saving authentication passwords. It already comes bundled with TortoiseHg, so all you have to do is activate it by writing the following in your mercurial.ini file:

[extensions] mercurial_keyring= 

You will also have to associate your username with the push url by editing your repository-specific .hg\hgrc file like in the example below:

[paths] default = https://<your_username>@bitbucket.org/tortoisehg/thg 

For more details on associating your username with the url, see the Repository Configuration (SMTP) section of the Keyring extension page.