git-shell如何限制使用者ssh登陸執行個體

來源:互聯網
上載者:User

雖然git是分布式的版本管理系統,但對於Team 專案開發,通常還是會在單獨的伺服器上建立一個git server。類似於svn,git server也有好幾種配置方式。詳情,可以參見git的文檔http://git-scm.com/book/en/v2。這裡,主要是從上述文檔中摘出一部分,說明一下git-shell的用處。

假如,大家都使用ssh的方式來訪問:

$ git clone git@10.3.0.99:project.git

這就意味者,訪問者具有許可權可以ssh登陸到伺服器上:

$ ssh git@10.3.0.99

出於安全的考慮,我們最好限制使用者只能進行git push/pull,但無法登陸。這可以使用git-shell來完成。

查看一下git-shell的位置:

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

將git-shell的路徑添加到/etc/shells檔案中,然後修改git使用者的shell:

$ sudo chsh git

設定為/usr/bin/git-shell。這樣,如果再使用ssh方式登陸,則會報錯:

$ 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.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.