Krishna
Krishna

Reputation: 1137

Jenkins Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password)

On Jenkins which is configured on a CentOS server, I am trying to connect to a git repository on another server using username and password. Unfortunately I am getting following error:

Failed to connect to repository : 
Command "/usr/bin/git -c core.askpass=true ls-remote -h ssh://root@[ip addres]:2020/opt/gitrepo/enpapp.git HEAD" 
returned status code 128:
stdout: 
stderr: Permission denied, please try again. 
Permission denied, please try again. 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 
fatal: Could not read from remote repository.*
Please make sure you have the correct access rights and the repository exists.

I am able to connect to git server using Putty.
Also I am able to clone git repository using Netbeans or command line.

The permission of .ssh folder is 700 and known_hosts file is 644

Upvotes: 11

Views: 13995

Answers (2)

Issmahane
Issmahane

Reputation: 11

I had the same issue . For my case I was wrongly pasting the private key in Jenkins. I was deleting the first and last part from the private key

-----BEGIN OPENSSH PRIVATE KEY----- &-----END OPENSSH PRIVATE KEY-----

So make sure that you copied all the content of your private key while creating SSH credentields on Jenkins.

Upvotes: 1

user8532358
user8532358

Reputation:

(Command "/usr/bin/git -c core.askpass=true ls-remote -h ssh://root@[ip addres]:2020/opt/gitrepo/enpapp.git HEAD")

From your logs, it is understood that Jenkins is trying to connect to the server using ssh-keys

you can generate proper keys using ssh-keygen and add the private key in Jenkins Credentials and the public key in your server account.

Its better if you can share the screenshot of your jenkins job showing how it is configured. Git plugin in Jenkins is not supporting Username and Password over ssh.
https://issues.jenkins-ci.org/browse/JENKINS-22909

Upvotes: 0

Related Questions