Create SSH user with limited privileges to only use Git repository

Solution 1:

You might consider using gitolite under a single user instead of setting up multiple git-shell users (and the required group and group permissions so they can share access to the repositories).

gitolite runs under a single, normal user on the server and uses SSH public keys to differentiate access to Git repositories (see “how gitolite uses ssh” for some of the details of how gitolite does its SSH-based identification). gitolite offers per-repository, per-branch, and even some per-path access control.

Solution 2:

You basically have two options.

  1. As topdog mentioned, when you create users on the server, set their shell to git-shell (book entry here). This will allow the user to login in via SSH, but instead of running a normal, fully-featured shell (e.g. sh,bash,etc.) it will run, git-shell, which only provides access to git functionality.

  2. Alternatively, you can make your repositories available via another protocol, such as TCP (using git-deamon) or HTTP/HTTPS. I'd only recommend such a scenario for read-only access though.

You mention wanting to support 'push' functionality for your users, so you should really go with option #1.

Solution 3:

you need to change their shell to git-shell, that will only give them access to git functions only.