A couple weeks ago, we went over how to establish a centralized git repository management system with Gitlab. Today, we’ll go over how to access the git server via SSH with Xshell.
In order to follow this guide, you’ll need git, Tortoisegit (git client Wrapper), and Xshell. You can download them from their respective official websites:
Git: https://git-scm.com/
Tortoisegit: https://tortoisegit.org/
Xshell: www.netsarang.com
Note: You must select Openssh Client when installing Tortoisegit. Reboot your system after installing git and Tortoisegit
Registering an SSH Public Key
Using Xshell you can create a private/public key and can deploy the public key in Gitlab. To read more about how to create a private/public key pair, see our guide here: http://blog.netsarang.com/1304/creating-a-publicprivate-key-pair-with-xshell/.
When you generate the key pair, select Key Type as RSA and Key Length as 2048. Select the User Key and export to %userprofile%/.ssh (Windows default home path: %userprofile%). If the .ssh folder does not exist, create a .ssh folder in %userprofile%. You must save the private key as “id_rsa” not “id_rsa_2048”.
Now go to your Gitlab control panel and navigate to Settings -> Deploy Keys. Click “New Deploy Key.”
Give the key a title and paste the public key generated in Xshell as shown below.
SSH to Git Server
Now that the keys are set, let’s SSH into the git server by cloning it. Go to your Gitlab project page. Set to SSH and copy the repository URL.
In your client machine navigate to the directory into which you want to clone the repository and right-click anywhere in the background of the file browser. Select “Git Clone.”
The URL field will be automatically filled with the repository’s URL. Click OK and you’ll be prompted to enter your passphrase.
Enter your passphrase, and then success!