Setting git private repository project on jenkins server
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h firstname.lastname@example.org:repo/project.git HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedl
What I have done up to now:
- transferring 0 files using publish over SSH plugin in Jenkins
- Managing SSH keys for Heroku from mac and windows
- Jenkins Pipeline based on groovy : unable to push into git => Permission denied (publickey)
- cant checkout external git repo in jenkins
- Capistrano SSH Connection
- Configure magit to use cygwin ssh with passphrase to push/pull from remote git repository
My server user and jenkin user( both are in same server) are different. Though it seems to me these are not related. jenkins user are given all credintial.
In my server under var/lib/jenkins/.ssh(.ssh is created by me) I added ssh key . Public key is added to github repo.
By swithcting user to jenkins i can clone the project by this ssh. So i think there is not any public key adding problem.
I have googled the problem. there are many solutions. I tried most of them. But still no solution. Probably I am missing something.
My repo url is something like this
2 Solutions collect form web for “Setting git private repository project on jenkins server”
HOME set in
/var/lib/jenkins/ then i hope all the step you have been done successfully 🙂
Then one thing may be happen for your case. Like when you switch the user by using:
This command means that you switch the user but the home directory will be same as a root’s home!
So you need to switch user by confirming the specific user home also switched. TO doing so, you need to follow:
su -s /bin/bash jenkins
Then you need to generate either the ssh public key once again or just update the known host. This will work.
It depends on what
HOME is set to when Jenkins is running: git will look for the ssh (public and private) keys under $H
Simply add a build step with an echo
$HOME, and make sure your
.ssh is in that folder.