简体   繁体   中英

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:
stdout: 
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 ;(

UPDATE

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM