Question

I'm trying to add a user for Jenkins (but any local user would do the same problem I guess) to connect to a Gitolite server which is on the same box.

  • I generated the SSH keys for Jenkins.
  • I added the public key to Gitolite's configuration.
  • I can connect to SSH on my localhost server with Jenkins.
  • I'm using SSH to connect to Gitolite

For example, the following does work:

sudo su jenkins
ssh localhost

But the following doesn't work :

sudo su - jenkins
git clone jenkins@localhost:my-repo

It's always saying

You appear to have cloned an empty repository

But the following does work :

sudo su - jenkins
git clone gitolite@localhost:my-repo

I think that I found why it doesn't work, but I want to know if there is an alternative.

There's a authorized_keys file inside gitolite's .ssh folder with a "command" and jenkins' public key. I guess this is to set the correct shell to use gitolite. However, there is also an authorized_keys inside Jenkins' ~/.ssh folder.

I guess that when I try to connect to gitolite using the user "jenkins", the "home" of jenkins is used instead of the gitolite repository so it's trying to find the repository inside Jenkins' home.

Is there a way I could use Jenkins (which is on the same box as the Gitolite server) to connect to gitolite without this problem?

Was it helpful?

Solution

The gitolite@ on the front of the URL is not actually the user as you use with SSH. It is the service (I assume) on the server so gitolite@localhost:my-repo is completely valid.

You will see a reference to git@ all the time when working with GIT. Your service is gitolite so gitolite@ will always be used.

Git servers authenticate using SSH public keys so the key you created is what allows the user to connect to the server. That key is also related to that user so when that key is used it is assumed that is the user issuing git commands such as a commit.

On a side note a colleague recommend http://documentup.com/skwp/git-workflows-book when I first started using our GIT system and it was a great help in understanding this truly wonderful version control system.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top