Setup git repository on gentoo server using gitosis & ssh

3

1

I installed git and gitosis as described here in this guide Here are the steps I took:

Server: Gentoo
Client: MAC OS X

1) git install

emerge dev-util/git

2) gitosis install

cd ~/src
git clone git://eagain.net/gitosis.git
cd gitosis
python setup.py install

3) added git user

adduser --system --shell /bin/sh --comment 'git version control' --no-user-group --home-dir /home/git git

In /etc/shadow now:

git:!:14665::::::

4) On local computer (Mac OS X) (local login is ipx, server login is expert)

ssh-keygen -t dsa

got 2 files:

~/.ssh/id_dsa.pub
~/.ssh/id_dsa

5) Copied id_dsa.pub onto server

~/.ssh/id_dsa.pub

Added content from file ~/.ssh/id_dsa.pub into file ~/.ssh/authorized_keys

cp ~/.ssh/id_dsa.pub /tmp/id_dsa.pub
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

6) Added 2 params to /etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes

Full sshd_config:

Protocol 2
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
UsePAM yes
PrintMotd no
PrintLastLog no
Subsystem   sftp   /usr/lib64/misc/sftp-server

7) Local settings in file ~/.ssh/config:

Host myserver.com.ua
User expert
Port 22
IdentityFile ~/.ssh/id_dsa

8) Tested:

ssh expert@myserver.com.ua

Done!

9) Next step. There I have problem

git clone git@myserver.com.ua:gitosis-admin.git
cd gitosis-admin

SSH asked password for user git. Why ssh should allow me to login as user git? The git user doesn't have a password. The ssh key I created is for the user expert. How this should work?

Do I have to add some params to sshd_config?

user28373

Posted 2010-02-25T21:36:04.027

Reputation: 31

Answers

3

As a notice for anybody who finds this question in the future, I would like to point out that gitosis has been declared as deprecated by the majority of the git community and appears to be abandoned by its author.

Gitolite has become its successor and is unanimously agreed to be superior in every way, most importantly being ease of use, troubleshooting, and debugging.

Arrowmaster

Posted 2010-02-25T21:36:04.027

Reputation: 626

0

It looks like you missed a couple steps from the guide. After setting up the ssh keys it says:

Next we will run a command that will sprinkle some magic into the home directory of the git user and put your public SSH key into the list of authorized keys.

sudo -H -u git gitosis-init < /tmp/id_rsa.pub

and...

For good measure, let's make sure the post-update hook is set executable. I've seen it where sometimes it doesn't get set (problem with older setuptools):

sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

then you want to do the step you were having trouble with:

git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
cd gitosis-admin

heavyd

Posted 2010-02-25T21:36:04.027

Reputation: 54 755

Thanks, but I did this on step 5 sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

But ssh asked a password... – user28373 – 2010-02-25T22:14:51.460

0

On step 5, you don't need to add the key to ~/.ssh/authorized_keys file yourself... the gitosis-init does that for you.

And on your client side, in the ~/.ssh/config file the settings should be:

Host myserver.com.ua
User git
Port 22
IdentityFile ~/.ssh/id_dsa

since you want the password-less login to happen for the git user on the server.

kartikmohta

Posted 2010-02-25T21:36:04.027

Reputation: 586