4

Im trying to setup jekins with Git by ssh.

Standard execute:

git clone ssh://[username]@[server]/srv/git/[repo]

after putting password repositorium is cloned on my disk.

Now on jenkins

ssh://[username]@[server]/srv/git/[repo].git

Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://[username]@[server]/srv/git/[repo].git HEAD" returned status code 128:
stdout:
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

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

enter image description here

enter image description here

or another way is enter image description here

user2856064
  • 541
  • 1
  • 8
  • 25

4 Answers4

1

You're connecting by SSH, which likely means you've got a key-based login set up so that you can connect without a password. (Move ~/.ssh/id_rsa to some other location, and I'm pretty sure you'll be asked for a password when you do a git clone as well.)

In this case the error is a result of Jenkins not having a similar private key setup. You have to generate a public/private key pair for jenkins, and add the public key to your git server, or add your private key to Jenkins.

Related question & answer: https://stackoverflow.com/a/8911280/223981

Community
  • 1
  • 1
Kyle
  • 4,205
  • 1
  • 21
  • 22
1

I had the same error report while I was using credentials of kind "SSH Username with private key". For the private key, I selected "From a file on Jenkins master" and provided as file location ~/.ssh/some-project-specific-directory/id_rsa.

It turned out that Jenkins version 1.637 has problems with the tilde home notation ("~"). After I changed to the expanded absolute path (e.g. /var/lib/jenkins/.ssh/some-project-specific-directory/id_rsa) everything worked well again.

Abdull
  • 26,371
  • 26
  • 130
  • 172
1

In our environment, with multi slave configuration, the issue was with the master. Basically our slaves are configured to connect to git repo, but not the master, as we do not execute any jobs on master.

The above error is due to master trying to connect to your git repo. Hence, either make sure your master is configured properly to access your git repo, or just ignore this error and run your job to see if it executes fine on the slave.

Lidia
  • 2,005
  • 5
  • 25
  • 32
  • Same cause in our setup. One job didn't have node restriction and it started "randomly" failing on checkout (when executed on server without valid keys). – user158037 Sep 26 '17 at 10:20
-2

Just add password in the 'passphrase' section when you add ssh key, because you have the private key but it still needs password to connect to the repo.

See the image below