ssh: Could not resolve hostname gitlab.com:user_name/repo_name.git: Name or service not known

Viewed 628

I am trying to connect my jenkins server to my private repository on gitlab.com. I have already added the API access token of gitlab to my jenkins server and added the Jenkins public key to the ssh-keys of gitlab account.

Upon adding my gitlab repository to my jenkins pipeline I get below error:

Failed to connect to repository : Command "git ls-remote -h -- git@gitlab.com:user_name/repo_name.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

When I try to run the following command on my Jenkins server:

ssh -T  git@gitlab.com:user_name/repo_name.git 

I get the following error:

ssh: Could not resolve hostname gitlab.com:user_name/repo_name.git: Name or service not known

I am not able to figure out the reason why my Jenkins server is unable to access the repository even after providing the SSH Keys and the Access Token.

1 Answers

API access token of gitlab

That would be use for HTTPS access.

added the Jenkins public key to the ssh-keys of gitlab account

That is relevant for SSH URL, and means you need to set the right credentials in your Jenkins job (the credential referencing the Jenkins private key, whose public key was published to GitLab)

I would test first on Jenkins server:

ssh -Tv git@gitlab.com

Check also the content of your Jenkins server running account ~/.ssh/config file for any gitlab.com Host entry.

Related