Git-shell How to restrict user SSH login instances

Source: Internet
Author: User
Tags documentation ssh using git git clone git shell

Although Git is a distributed version management system, for team project development, it is common to create a git server on a separate server. Similar to Svn,git server, there are several ways of configuring it. For more information, refer to Git's documentation http://git-scm.com/book/en/v2. Here, the main is from the above document to pick out a part, explain the usefulness of Git-shell.

If you are using SSH to access:

$ git clone git@10.3.0.99:project.git

This means that visitors have permissions to ssh to the server:

$ ssh git@10.3.0.99

For security reasons, we'd better limit the user to only Git push/pull, but not login. This can be done using Git-shell.

Check out the location of the Git-shell:

$ which Git-shell
/usr/bin/git-shell

Add the Git-shell path to the/etc/shells file, and then modify the git user's shell:

$ sudo chsh git

Set to/usr/bin/git-shell. This way, if you use SSH to log in again, you will get an error:

$ ssh git@10.3.0.99
git@10.3.0.99 ' s Password:
Welcome to Ubuntu 14.04.1 LTS (gnu/linux 3.13.0-35-generic x86_64)

* documentation:https://help.ubuntu.com/

Fatal:interactive git shell is not enabled.
Hint: ~/git-shell-commands should exist and have read and execute access.
Connection to 10.3.0.99 closed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.