Upgraded Jenkins to 2.332.1 and a few plugins to try to stay up to date. Now getting the following error:
`Failed to connect to repository : Command “/usr/bin/git ls-remote -h git-repo-link HEAD” returned status code 128:
stderr: ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.`
I have no problem cloning the repo from command line. I have tried deleting the workspace, downgrading a few of the plugins, adding the Wipe out repository & force clone in Additional Behaviors under Source Code Management, and a few others.
I can connect to my repo without problem from command line by cloning and/or running ssh -T git@repo-url
I’m not aware of anything in the upgrade to 2.332.1 that would break ssh credentials, so long as you followed the instructions in the upgrade guide and updated all plugins.
Are you certain that the credential you’re using in the Jenkins job definition is the same credential that is being used in the case where command line git is able to clone the repository? Sometimes a user will have a working local configuration but the credential that was used in the Jenkins job no longer has permissions to perform the operations it performed before.
I have created new credentials in the UI to make sure the right private key was being used within the job and am still experiencing this problem. I am on CentOS 7.4.
I can revisit permissions. I can see that the jenkins user has ownership and access to the ssh directory and the private key within that directory that is used for connecting to our repo. Are there specific permissions that directory and private key file need in order for the jenkins user to successfully access them from a job?
All plugins are up to date … only message I have is the screenshot I posted above that relates to the Credentials plugin which makes it seem like it isnt actually offered for installation? Do you think downgrading that plugin may help?
I don’t know if that’s the cause, but CentOS 7.4 is a very old version of CentOS 7. The current version is CentOS 7.9.
I doubt that downgrading that plugin will change it. The message that is being displayed is an expected message because a version of the credentials plugin is available that requires a Jenkins version newer than the Jenkins version you are running. The following Jenkins blog post describes that message in more detail
You could certainly experiment with other versions of the credentials plugin, but my suspicion is that the problem is related to file or directory permissions or something similar, not to plugin versions.
Thank you for your help. I am going to keep working on debugging. What has been really odd is that when I ssh onto the host and change user to the jenkins user I can clone and connect to the repo no problem. The second I try to run ssh -T git@repo-url in an execute shell I get ssh_exchange_identification: Connection closed by remote host. I can also verify by running whoami in the execute shell that the jenkins user is running those commands.
Im unsure what the difference is between me running those commands as the jenkins user in command line and the jenkins user running those commands from the execute shell in a job.
I have created brand new ssh username and private key credentials using the Jenkins UI using a private key I know connects to my repo properly. When setting up my repo in a job under Source Code Management, Git refuses to connect to my repository properly.
Are there any logs that I can look at for the git plugin or other plugins that may be related to this? Otherwise, I am only trying to debug off of logs that are coming out of the failed job itself. This is really frustrating and is making me hesitate to use and ever upgrade Jenkins in the future
Thanks Mark. That didnt provide too much more information. Atleast not much that appears to be all that helpful unfortunately. I am beginning to consider opening a bug report with Jenkins for continued support working through this.