<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 配置服務器 我們來看看如何配置服務器端的 SSH 訪問。本例中,我們將使用 `authorized_keys` 方法來對用戶進行認證。同時我們假設你使用的操作系統是標準的 Linux 發行版,比如 Ubuntu。首先,創建一個操作系統用戶 `git`,并為其建立一個 `.ssh` 目錄。 ~~~ $ sudo adduser git $ su git $ cd $ mkdir .ssh && chmod 700 .ssh $ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys ~~~ 接著,我們需要為系統用戶 `git` 的 `authorized_keys` 文件添加一些開發者 SSH 公鑰。假設我們已經獲得了若干受信任的公鑰,并將它們保存在臨時文件中。與前文類似,這些公鑰看起來是這樣的: ~~~ $ cat /tmp/id_rsa.john.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCB007n/ww+ouN4gSLKssMxXnBOvf9LGt4L ojG6rs6hPB09j9R/T17/x4lhJA0F3FR1rP6kYBRsWj2aThGw6HXLm9/5zytK6Ztg3RPKK+4k Yjh6541NYsnEAZuXz0jTTyAUfrtU3Z5E003C4oxOj6H0rfIF1kKI9MAQLMdpGW1GYEIgS9Ez Sdfd8AcCIicTDWbqLAcU4UpkaX8KyGlLwsNuuGztobF8m72ALC/nLF6JLtPofwFBlgc+myiv O7TCUSBdLQlgMVOFq1I2uPWQOkOWQAHukEOmfjy2jctxSDBQ220ymjaNsHT4kgtZg2AYYgPq dAv8JggJICUvax2T9va5 gsg-keypair ~~~ 將這些公鑰加入系統用戶 `git` 的 `.ssh` 目錄下 `authorized_keys` 文件的末尾: ~~~ $ cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys $ cat /tmp/id_rsa.josie.pub >> ~/.ssh/authorized_keys $ cat /tmp/id_rsa.jessica.pub >> ~/.ssh/authorized_keys ~~~ 現在我們來為開發者新建一個空倉庫。可以借助帶 `--bare` 選項的 `git init` 命令來做到這一點,該命令在初始化倉庫時不會創建工作目錄: ~~~ $ cd /opt/git $ mkdir project.git $ cd project.git $ git init --bare Initialized empty Git repository in /opt/git/project.git/ ~~~ 接著,John、Josie 或者 Jessica 中的任意一人可以將他們項目的最初版本推送到這個倉庫中,他只需將此倉庫設置為項目的遠程倉庫并向其推送分支。請注意,每添加一個新項目,都需要有人登錄服務器取得 shell,并創建一個裸倉庫。我們假定這個設置了 `git` 用戶和 Git 倉庫的服務器使用 `gitserver` 作為主機名。同時,假設該服務器運行在內網,并且你已在 DNS 配置中將 `gitserver` 指向此服務器。那么我們可以運行如下命令(假定 `myproject` 是已有項目且其中已包含文件): ~~~ # on John's computer $ cd myproject $ git init $ git add . $ git commit -m 'initial commit' $ git remote add origin git@gitserver:/opt/git/project.git $ git push origin master ~~~ 此時,其他開發者可以克隆此倉庫,并推回各自的改動,步驟很簡單: ~~~ $ git clone git@gitserver:/opt/git/project.git $ cd project $ vim README $ git commit -am 'fix for the README file' $ git push origin master ~~~ 通過這種方法,你可以快速搭建一個具有讀寫權限、面向多個開發者的 Git 服務器。 需要注意的是,目前所有(獲得授權的)開發者用戶都能以系統用戶 `git` 的身份登錄服務器從而獲得一個普通 shell。如果你想對此加以限制,則需要修改 `passwd` 文件中(`git` 用戶所對應)的 shell 值。 借助一個名為 `git-shell` 的受限 shell 工具,你可以方便地將用戶 `git` 的活動限制在與 Git 相關的范圍內。該工具隨 Git 軟件包一同提供。如果將 `git-shell` 設置為用戶 `git` 的登錄 shell(login shell),那么用戶 `git` 便不能獲得此服務器的普通 shell 訪問權限。若要使用 `git-shell`,需要用它替換掉 bash 或 csh,使其成為系統用戶的登錄 shell。為進行上述操作,首先你必須確保 `git-shell` 已存在于 `/etc/shells` 文件中: ~~~ $ cat /etc/shells # see if `git-shell` is already in there. If not... $ which git-shell # make sure git-shell is installed on your system. $ sudo vim /etc/shells # and add the path to git-shell from last command ~~~ 現在你可以使用 `chsh <username>` 命令修改任一系統用戶的 shell: ~~~ $ sudo chsh git # and enter the path to git-shell, usually: /usr/bin/git-shell ~~~ 這樣,用戶 `git` 就只能利用 SSH 連接對 Git 倉庫進行推送和拉取操作,而不能登錄機器并取得普通 shell。如果試圖登錄,你會發現嘗試被拒絕,像這樣: ~~~ $ ssh git@gitserver fatal: Interactive git shell is not enabled. hint: ~/git-shell-commands should exist and have read and execute access. Connection to gitserver closed. ~~~ 現在,網絡相關的 Git 命令依然能夠正常工作,但是開發者用戶已經無法得到一個普通 shell 了。正如輸出信息所提示的,你也可以在 `git` 用戶的家目錄下建立一個目錄,來對 `git-shell` 命令進行一定程度的自定義。比如,你可以限制掉某些本應被服務器接受的 Git 命令,或者對剛才的 SSH 拒絕登錄信息進行自定義,這樣,當有開發者用戶以類似方式嘗試登錄時,便會看到你的信息。要了解更多有關自定義 shell 的信息,請運行 `git help shell`。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看