How to link a SQL Server database to a Mercurial repository using the SSH protocol

Applies to

ApexSQL Source Control

Summary

This article explains how to link a database to the Mercurial repository using the SSH protocol generated by PuTTY in this database source control tool.

Description

This database source control system tool supports four different protocols that can be used to connect to the Mercurial repository: HTTP, HTTPS, SSH, and File protocol.

In this article will be explained how to connect to the Mercurial repository using SSH protocol. There are several ways to make an SSH key, for this purpose in this article will be applied to the Putty freeware open-source software.

Generating an SSH key

Putty is an SSH client for Windows, who can be practiced for creating SSH keys also. When the Putty client is installed, also the PuTTYGen utility is installed next to it. The PuTTYGen is used for creating the SSH keys. When clicking on the PuTTYGen utility, the PuTTY Key Generator window will be opened. In the PuTTY Key Generator window, by default, will be selected the RSA type of the key and 2048 number of bits in the generated key. To create an SSH key click on the Generate button:

The Generate button in the PuTTY Key Generator window

After clicking on the Generate button, the progress bar will be shown, and an SSH key will be generated by moving the pointer of the mouse in the scope below that:

The progress bar

When a progress bar is filed, an SSH key was generated. Passphrase could be added in the Key Passphrase and Confirm passphrase fields, that fields are not mandatory. The SSH key can be saved without a passphrase, but that is not recommended:

The Key passphrase in the PuTTY Key generate dialog

After the SSH key is generated. By clicking on the Save public key and Save private key, an SSH key will be saved:

Save public key and Save private key buttons

By default, the private key id_rsa.ppk and the public key id_rsa.pub will be saved in the C:\Users\<user name>\.ssh folder:

SSH folder

When the public and private key is saved, the generate key from Public key for pasting into OpenSSH authorized_keys file field is using for storing in the database source control repository:

The SSH key for source control repository

When a generated key is stored in the source control repository, now a selected database can be linked in the Mercurial repository with SSH authentication.

Link a selected database with SSH protocol

In this database source control tool, to link a database in the Mercurial source control system, with an SSH key authentication, go to the Object Explorer panel. In the Object Explorer panel, right-click on the selected database, and choose the Link database to source control command:

The Link database to source control command from the right-click context menu

The Source control setup window will be opened, in the Connection type tab choose the Mercurial source control system:

The Connection type tab of the Source control setup window

When the Mercurial source control system is selected, go to the System login tab and choose SSH protocol:

SSH protocol in the System login tab

In the Key pair path field, enter the path of the private SSH key C:\Users\<name of the users>\.SSH\Id_rsa.ppk. The other fields (Repository, Branch, Project) of the System login tab, as well as all about the linked procedure, will be explained in the How to link a SQL Server database to a source control system article. When all fields from the System login tab are filled, by clicking on the Finish button, the selected database will be linked to the Mercurial source control system using SSH protocol:

Key pair path from the System login tab

FAQs

Q: Which source control systems can use SSH protocols to login to the repository?

A: In this database source control tool, Git, Mercurial, and Subversion source control systems are using the SSH protocols to connect into the repository.