Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a restricted SSH account for a GIT repository?

Tags:

git

linux

How is the best way I can create a jailed user on a Linux machine to be used solely for a git repository?

like image 842
Void Avatar asked May 21 '11 10:05

Void


2 Answers

git-shell is a restricted shell that you can use for this purpose.

If you make set a user's login shell to git-shell then he can only run a limited set of server-side git helper functions which enable remote git over ssh usage but don't permit a normal log in.

like image 103
CB Bailey Avatar answered Sep 21 '22 22:09

CB Bailey


Also look in to gitosis. In particular, it sets some parameters in .ssh/authorized_keys which prevent port forwarding, etc:

command="gitosis-serve user@host",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA....

Even if you do not use gitosis, you may want to include the restrictive options.

like image 36
Dean Serenevy Avatar answered Sep 20 '22 22:09

Dean Serenevy