Went through a lot of questions, but nothing seems to be solving my issue. Or to be more precise I am not sure if I am doing the whole thing correctly. So here it is:
Have installed centos 6.3 OS. Then I followed the following guide to install jenkins:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions
Jenkins works fine. Now I am trying to set up a simple build job, which requires to clone a git repository. (I've installed git plugin)
In repository URL i type the following: git@gitserver:myrepo.git Of course I get an error: stderr: Host key verification failed.
ok, I need to generate ssh keys and all will be good. So I do the following:
su - jenkins
but unfortunately it doesn't switch to jenkins user.
cat /etc/passwd
shows the following:
jenkins:x:496:492:Jenkins Continuous Build Server:/var/lib/jenkins:/bin/false
so seems that it doesn't have a usual home directory.
The question is how do I generate keys for jenkins or if the above steps where not the right way to do it, how do I fix it?
Thanks a lot!
Update: I generated keys (as a root user) and placed them in jenkins home and did exactly and copied public key to git server. Still didn't help.
When I look at the log of the build it says:
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/myrepo/workspace
this user anonymous is this another user created by jenkins, or is it still jenkins that runs the commands?
Add SSH Key inside JenkinsIn the dropdown, select 'SSH username with private key' and then give a name for it. Copy the private key from the Jenkins server. Now you can clone any git repo in this Jenkins instance. You do not need to provide the credentials while configuring the job in Jenkins.
Add SSH Key inside Jenkins Now go to Credentials from left pane inside Jenkins console and then click global: Then Go to add new credentials. Kind dropdown, select 'SSH username with private key'.
From the Jenkins home page (i.e. the Dashboard of the Jenkins classic UI), click Manage Jenkins > Manage Credentials. Under Stores scoped to Jenkins on the right, click on Jenkins. Under System, click the Global credentials (unrestricted) link to access this default domain. Click Add Credentials on the left.
You can generate a key with Putty key generator, or by running the following command in git bash: $ ssh-keygen -t rsa -b 4096 -C [email protected]. Private key must be OpenSSH. You can convert your private key to OpenSSH in putty key generator. SSH keys come in pairs, public and private.
I'm assuming that you have root access if you were able to install the Jenkins RPM. Were you su-ing to the jenkins user while logged in as root ? If not, you should do so or use
sudo su - jenkins
if your logged in user has sudo access.
Then run
ssh-keygen -t rsa
to generate an RSA keypair for the jenkins user, and you can upload the public key to your git server. The key will be generated as /var/lib/jenkins/.ssh.id_ra.pub if you take the defaults.
1 change user jenkins login setting
vi /etc/passwd
update /bin/false to /bin/bash
2 su - jenkins
jekins user home would be /var/lib/jenkins
3 ssh-keygen
cat .ssh/id_rsa.pub
copy this key to bitbucket
4 ssh [email protected]
this is going to set the bitbucket ssh key in .ssh/known_hosts
Now you should be able to access
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With