Setting Up Users, Permissions and Groups for SSH Access to a Shared Git Repository

If you are having permission problems using git, such as

error: insufficient permission for adding an object to repository database ./objects

There are a couple thing you can do to remedy the situation, before moving to a full on git server like gitosis.

Create your users and add them to a group. Create (if you haven’t already) your git repo on the server and change permission and ownship and set the git config sharedRepository to true.

Here are all the commands, quick and dirty!

adduser sean
adduser jackson
groupadd developers
adduser sean developers
adduser jackson developers

mkdir -p /git/dev/app.git
cd /git/dev/app.git
git --bare init
vim description  #edit this file (mac os x complains otherwise)
chmod -R g+ws *
chgrp -R developers *
git repo-config core.sharedRepository true

Found from: http://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html

Adding Public/Private Key Pairs on Mac OS X and Ubuntu for Passwordless Remote SSH Sessions

On your local machine cd into the .ssh directory in your home “~/” directory. If it doesn’t exist you can create it with “mkdir ~/.ssh”. Next generate your public/private keys and copy the public key to the remote server.

cd ~/.ssh
ssh-keygen -t rsa -b 4096
# will take a couple seconds but when finished
# specify a full path (if there is already an existing key) or hit enter to install to the default location ~/.ssh
# when it prompts for a passphrase just hit enter
# and enter again when it asks to confirm the passphrase
# then we copy the public key the remote server (this assumes you don't already have an authorized_keys file)
# copy and paste the contents of the id_rsa.pub file into the authorized_keys file otherwise
scp id_rsa.pub user@yourdomain.com:.ssh/authorized_keys

You’ll need to edit your ssh config file and restart the process to allow for public/private key authentication.

vim /etc/ssh/ssh_config
# add or uncomment these two lines
RSAAuthentication yes
PubKeyAuthentication yes
# ... and restart
/etc/init.d/ssh restart

Troubleshooting

A couple of things to keep in mind. 1) Permissions matter. Make sure that your keys are not world readable (this should be secure) Run chmod 400 on authorized_keys file.

If you had a set of keys already setup in .ssh/ on your local machine and want to install the new keys in another directory so as not to overwrite the old pair, you need to add them to ssh with this command

ssh-add ~/full/path/to/your/new/keys

More information is available here http://www.debian-administration.org/articles/152

6 Sep 2009, 3:25pm
Git:
by

leave a comment

Non Standard Port Number with SSH and Git

Here is an example using the port 4567 to connect with over ssh and git

ssh remote add origin ssh://sean@seanbehan.com:4567/path/to/git
git push origin master
10 Aug 2009, 12:46pm
Linux:
by

leave a comment

Change default ssh port number on Ubuntu

Login as the root user or as a user that can execute sudo commands.

#open this file for editing...
vim /etc/ssh/sshd_config

Find the line that reads

Port 22

Change this to an different and an available port number…

Port 8000

Next reload ssh

/etc/init.d/ssh reload

You won’t be kicked out of your session. But if you want to open a new connection to your server you need to specify the port number for the connection.

ssh -p8000 root@yourdomain.com