I can clone my git repository on the Linux server that hosts the Jenkins app, but when I'm trying to create a new Jenkins job to do so, I'm getting error 128.
"Failed to connect to repository : Command "git ls-remote -h ssh://git@bitbucket.org/user/proj.git HEAD" 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."
Things I did
Install git on the Linux server.
Install BitBucket plugin and it's dependencies on the Jenkins app.
Create an SSH key.
WORKS ON TERMINAL
bash-4.2$
bash-4.2$ whoami
jenkins
bash-4.2$ ssh -T git@bitbucket.org
authenticated via a deploy key.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
This deploy key has read access to the following repositories:
user/proj: test3 -- jenkins@git
.
.
git -c core.askpass=true ls-remote -h ssh://git@bitbucket.org/user/proj.git
[ec2-user@ip-172-31-31-13 ~]$ git -c core.askpass=true ls-remote -h ssh://git@bitbucket.org/user/proj.git
db710fbf01f08789cf5c15e66269013f8e1543d4 refs/heads/master
IMAGES:
2-ssh 2 git using default user
I would try to write the URL of the git repository, when configuring it in Jenkins, as git@[...]
instead of ssh://git@[...]
On the other hand, the key you have introduced as private key of test3
(ssh-rsa AAA[...]
) doesn't seem to be a private key. It looks like the public key instead. The private key is a block that starts with -----BEGIN RSA PRIVATE KEY-----
and ends with -----END RSA PRIVATE KEY-----
. In your case I think it's stored in the file named jenkins_bitbucket_access
(the public key is stored in jenkins_bitbucket_access.pub
)