6

I have setup a gitosis server following instructions from here. It works fine for the initial user but I have recently added a new user. Here are the steps I took.

  • Created an rsa keypair using ssh-keygen with filename johndoe.
  • Then copied it to the keydir in gitosis admin repo.
  • Edited the gitosis config file and added user johndoe to the list of members
  • Commited the changes using git commit -a -m "what i did"
  • Pushed the changes to the server

After that I tried to check out with the new keyfile. It asks for the passphrase and when I enter it correctly, it the asks for the password for user git!!! There is not password for user git.

Now I have turned off PasswordAuthentication in sshd_config and now it says 'Permission denied (publickey). I have checked the git user's authorized_keys file and only one key is authorized inside it, i.e. the initial key for the gitosis admin.

I have also double checked the permissions on the ./gitosis-admin.git/hooks/post-update hook and it has 755

andho
  • 1,166
  • 1
  • 15
  • 27
  • I don't even remember what I did to solve this or if I even did solve it. I currently use gitolite and feel it's much better. What should be done to a question like this? – andho Jul 17 '11 at 17:01

7 Answers7

6

Gitosis is kind of stupid — is the filename you used for the keyfile literally "johndoe"? If so, change that:

git mv keydir/johndoe keydir/johndoe.pub
git commit -m "changed key name"
git push

and try again.

Also, as Arlen Cuss points out, make sure it actually is the public key, not the private key.

ebneter
  • 20,795
  • 9
  • 30
  • 30
  • OP, if the issue is the public vs. private key, please accept Arlen Cuss's answer. I'm leaving this here for those people who've left the ".pub" off of public keys. – ebneter Feb 03 '11 at 19:57
  • To be honest I have no idea what gitosis *does* do if a private key is put in instead, but I assume it won't function, and that this may be the issue .. who knows :-} – Asherah Feb 04 '11 at 06:58
  • @Arlen Cuss, it will install the private key in the authorized keys file, and then ssh won't work. (I've had people do it. :-) ) – ebneter Feb 04 '11 at 22:58
5

Hi, I had the same problem, and I finally found a way out.

I had to follow the instructions given by many websites, but each time after

git clone git@[serveur_name]:gitosis-admin.git

It was asking password for GIT.

Resolution: I have inserted the admin public key (the one created on my client user; then imported into the server's tmp directory) inside my authorized_keys file (located in the /home/git/.ssh/ directory of the server) and it works now.

 cp authorized_keys authorized_keys.bak
 cat /tmp/id_dsa_git.pub >> authorized_keys

I found this @ http://fclose.com/b/linux/366/set-up-git-server-through-ssh-connection/

eeerahul
  • 1,629
  • 4
  • 27
  • 38
lutinwood
  • 91
  • 1
  • 3
1

Make sure you're putting your public key inside your gitosis repo, and not your private one!

When you generate a keyfile, you'll get a .pub file—use that one, but put the name in your gitosis.conf without the .pub.

Asherah
  • 18,948
  • 5
  • 53
  • 72
1

Make sure you have also added (git add) the .pub-files, and committed and pushed them properly to the repository.

Marcus E
  • 11
  • 1
0

one thing that often goes wrong for windows users and isn't catched by most of the tutorials out there (since they assume you're on a linux client)

msysgit, the windows git console, is looking for your private key at /home/YOURUSERNAME/.ssh/id_rsa which at windows is (Windows 7) C:\Users\YOURUSERNAME.ssh\id_rsa

while most get it right with the folder, since its created automaticly, they miss that the file HAS TO be named "id_rsa" or it wont be used by msysgit. I didn't find a way to tell msysgit to use other keys

omni
  • 4,104
  • 8
  • 48
  • 67
0

Most likely what happened is that the post-update hook didn't run properly.

Check that ~git/.ssh/authorized_keys has your public key in it.

If not, the post-update hook didn't run. Permissions which have subsequently been changed? Some other configuration error. Copied from somewhere else?

  1. On the server, checkout gitosis admin: git clone /path/to/gitosis-admin.git. Make an insignificant change to gitosis.conf. Check that your public key is in keydir. I had to run this as the git user.

  2. Commit gitosis.conf. git add gitosis.conf && git commit -m "refresh keys".

  3. Now check authorized_keys file.

  4. Change gitosis.conf back and commit again.

Test access. If authorized_keys isn't updated after this process, look in logs for error messages.

Interlated
  • 5,108
  • 6
  • 48
  • 79
0

I recently ran into this issue with a private repository for work. I came across this answer and read the answers; this and this did the trick.

To sum it up for posterity, make sure you add the .pub key to the gitosis-admin/keydir directory. It has to be a .pub file.

Commit & Push your changes to gitosis-admin.

Your ~/.ssh/authorized_keys will be automatically updated so no need to cat-redirect the output of your public key file to it.

Hope this helps

Community
  • 1
  • 1
Zack
  • 2,477
  • 4
  • 37
  • 50