I have installed Jenkins in CentOS and also installed git plugin so as to use Bitbucket. When adding Repository URL in Source Code Management, HTTPS works good but when I add SSH url the following error pops up -
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h firstname.lastname@example.org:ash_dy/test_1.git HEAD" returned status code 128:
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have finally found solution for my problem, I am posting it here for others.
Configure the shell for the jenkins user by editing
/etc/passwd/ and changing
su - jenkins. Note the jenkins user's home is
cat .ssh/id_rsa.pub and copy this key to your bitbucket account
ssh email@example.com to set the bitbucket ssh key in .ssh/known_hosts
Now you should be able to access bitbucket from Jenkins.