Git Connector with SSH Key Authentication Fails to Connect

Problem Statement:

Harness user experiencing Error while setting up Git connector using SSH Credentials

If a git connector is improperly set up, often a not authorized message will appear as well as the Connection test fill fail. The issue is very likely caused by the SSH key that is being used for the connector.

Scenario:

While setting up a git or Github connector in Harness NextGen UI

Solution:

Solution Summary:

This issue is often caused by the username of the SSH key object is not of a value needed in order to access the specified resource. In this case git.

Here are steps that can be followed to resolve this issue.

  1. Go to the problematic Connector. In my example, this is a git connector, and select Edit Details.

  1. Overview Page: Set Name, Description, and Tag(s)

  2. Details Page:

  3. URL Type β†’ Select either Account or Repository

  4. Connection Type β†’ Select SSH

  5. Github Account URL β†’ example: [email protected]:accountname

  6. Test Repository β†’ enter in the repo name that is used to test the credentials

  1. Credentials Page:

  2. Select Create or Select a Secret inside the SSH Key field

  3. This will create a dialog box where you can either select new SSH Credentials or use existing Credentials. For this scenario, we believe that the SSH credentials that might have been used initially were set up incorrectly.

Steps to correct the SSH Credentials

  1. Either by following the previous steps or by going to the Secrets module of either the

  2. Account: Account Settings β†’ Account Resources β†’ Secrets

  3. Organization: Organization Resources β†’ Secrets

  4. Project: Project Setup Drop Down menu β†’ Secrets

  5. In the New Secret Drop Down, select SSH Credentials

  6. SSH Details Page

  7. Select Name as well as optionally the Description and Tags

  8. Configuration and Authentication

  9. Select an Auth Scheme β†’ Select SSH Key

  10. Select Username/ SSH Key

  11. Username: This is where you want to select the user name that Harness will use with the SSH command to access the external resource. In this case it will be β€˜git’

  12. Select or create an SSH key File. The key file will have your secret key that Harness will use for authentication

  13. Select Passphrase that will be used with the key file

  14. Select SSH Port number

  1. Verify Connection

  2. Add a Host Name to start verification. Example: github.com

Finishing the Github connector setup

  1. Connect to Provider either via Harness Platform or from a Harness Delegate
  2. Finish the process to test the connection
1 Like