Git: Creating a new user for git secure remote push

Here’s a quick how-to to create a new user for git. The assumes you already have a functioning secure git server already running.

Start out by creating the user, note were changing the shell to git’s own git-shell.

adduser -b /home/git -g git -m -s /usr/bin/git-shell kelsey -p

After the user is created, create a openssh key for the new user.

mkdir /home/git/kelsey/.ssh
ssh-keygen -n kelsey -t dsa -f kelsey/.ssh/id_dsa

And lastly secure the directory back down.

chown -R kelsey:kelsey /home/git/kelsey
chmod -R u=rwX,go-rwx /home/git/kelsey/.ssh
chmod +rw /home/git/kelsey/.ssh/

Kelsey will now be able to push git updates to her branches.