Dawid Komorowski Dawid Komorowski - 1 year ago 233
Git Question

Jenkins issue with Git [Permission denied (publickey).] on Windows

I know that thousands of topics touch my problem but I am fighting this from several days with almost zero progress ;(.

I installed Jenkins on Windows machine.

Then acquired Git plugin and the Git itself.

Everything is latest version for the day of my writing.

I was just happy to start to play with Jenkins but I failed at configuring my Bitbucket repository to be used by Job.

I set the exact path to git.exe (as it seemed the reason for initial problems) [C:\Program Files\Git\cmd\git.exe].

Then I tried accessing the repository by HTTPS with account credentials, many strange errors here so I thought let's try with SSH.

I have generated rsa keys, set the public key in the Bitbucket repository. Then I created credential configuration in Jenkins for SSH authentication with passphrase.

I have many problems here so for temporary workaround I explicitly set the value of private key.

Finaly I got to the place where I am now:

+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

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

When I try to manualy copy repository, it politely asks me about passphrase and the copy is done. When Jenkins job does it the above happens. With help of %USERNAME% and %USERDOMAIN% in the Job's script I get the same values like when I do it manually.

After plenty of hours I can say I can't use Git in Jenkins ;(


I don't believe that it could be so simple. As mainframer mentioned, I left passphrase empty for the whole SSH authentication and it really worked (the repository is cloned even that Jenkins still shows the same error in job's configuration page). I only wonder about any consequences of such setup, but working thing is more valuable for me now.

Answer Source

You mean leaving empty passphrase while generating keys and then also no passphrase config in Jenkins ssh credentials?

Yes, as Jenkins wouldn't be able to feed the passphrase to the ssh session.

But make sure the Jenkins slave service runs with your account (and not with the system account). It needs your account to find the ssh keys in %USERPROFILE%\.ssh\id_rsa(.pub)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download