<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之旅 廣告
                # Signing commits with GPG > 原文:[https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/](https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/) * [How GitLab handles GPG](#how-gitlab-handles-gpg) * [Generating a GPG key](#generating-a-gpg-key) * [Adding a GPG key to your account](#adding-a-gpg-key-to-your-account) * [Associating your GPG key with Git](#associating-your-gpg-key-with-git) * [Signing commits](#signing-commits) * [Verifying commits](#verifying-commits) * [Revoking a GPG key](#revoking-a-gpg-key) * [Removing a GPG key](#removing-a-gpg-key) * [Rejecting commits that are not signed](#rejecting-commits-that-are-not-signed-premium) * [GPG signing API](#gpg-signing-api) * [Further reading](#further-reading) # Signing commits with GPG[](#signing-commits-with-gpg "Permalink") 版本歷史 * 在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/9546) . * 在 GitLab 10.1 中添加了子項支持. 您可以使用 GPG 密鑰對在 GitLab 存儲庫中進行的 Git 提交進行簽名. 如果可以驗證提交者的身份,則已簽名的提交將標記為" **已**驗證". 為了驗證提交者的身份,GitLab 需要他們的公共 GPG 密鑰. **注意:**術語 GPG 用于所有與 OpenPGP / PGP / GPG 相關的材料和實現. 目前尚不支持通過 GPG 驗證的標簽. 有關 GPG 的更多詳細信息,請參見[進一步閱讀](#further-reading)部分. ## How GitLab handles GPG[](#how-gitlab-handles-gpg "Permalink") GitLab 使用其自己的密鑰環來驗證 GPG 簽名. 它不訪問任何公鑰服務器. 對于要由 GitLab 驗證的提交: * 提交者必須具有 GPG 公鑰/私鑰對. * 提交者的公鑰必須已上傳到其 GitLab 帳戶. * GPG 密鑰中的一封電子郵件必須與提交者在 GitLab 中使用的**經過驗證的**電子郵件地址匹配. * 提交者的電子郵件地址必須與 GPG 密鑰中驗證的電子郵件地址匹配. ## Generating a GPG key[](#generating-a-gpg-key "Permalink") 如果您還沒有 GPG 密鑰,則以下步驟將幫助您入門: 1. 為您的操作系統[安裝 GPG](https://www.gnupg.org/download/index.html) . 如果您的操作系統具有`gpg2`安裝,更換`gpg`與`gpg2`在下面的命令. 2. 使用以下命令生成私鑰/公鑰對,這將產生一系列問題: ``` gpg --full-gen-key ``` **注意:**在某些情況下,例如 Windows 和其他 macOS 版本上的 Gpg4win,此處的命令可能是`gpg --gen-key` . 3. 第一個問題是可以使用哪種算法. 選擇所需的類型或按`Enter 鍵`選擇默認類型(RSA 和 RSA): ``` Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? 1 ``` 4. 下一個問題是密鑰長度. 我們建議您選擇`4096` : ``` RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) 4096 Requested keysize is 4096 bits ``` 5. 指定密鑰的有效期. 這是主觀的,您可以使用默認值,該值永遠不會過期: ``` Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 0 Key does not expire at all ``` 6. 通過輸入`y`確認您給出的答案是正確的: ``` Is this correct? (y/N) y ``` 7. 輸入您的真實姓名,與此鍵關聯的電子郵件地址(應與您在 GitLab 中使用的經過驗證的電子郵件地址匹配)和可選注釋(按`Enter`跳過): ``` GnuPG needs to construct a user ID to identify your key. Real name: Mr. Robot Email address: <your_email> Comment: You selected this USER-ID: "Mr. Robot <your_email>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O ``` 8. 在詢問時選擇一個強密碼,然后輸入兩次以確認. 9. 使用以下命令列出您剛剛創建的私密 GPG 密鑰: ``` gpg --list-secret-keys --keyid-format LONG <your_email> ``` 將`<your_email>`替換為您在上面輸入的電子郵件地址. 10. 復制以`sec`開頭的 GPG 密鑰 ID. 在以下示例中,即`30F2B65B9246B6CA` : ``` sec rsa4096/30F2B65B9246B6CA 2017-08-18 [SC] D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA uid [ultimate] Mr. Robot <your_email> ssb rsa4096/B7ABC0813E4028C0 2017-08-18 [E] ``` 11. 導出該 ID 的公共密鑰(替換上一步中的密鑰 ID): ``` gpg --armor --export 30F2B65B9246B6CA ``` 12. 最后,復制公鑰并將其[添加到您的個人資料設置中](#adding-a-gpg-key-to-your-account) ## Adding a GPG key to your account[](#adding-a-gpg-key-to-your-account "Permalink") **注意:**添加密鑰后,就無法對其進行編輯,只能將其刪除. 如果粘貼無效,則必須刪除有問題的密鑰并重新添加. 您可以在個人資料的設置中添加 GPG 密鑰: 1. 點擊右上角的頭像,然后轉到**"設置"** . [![Settings dropdown](https://img.kancloud.cn/45/75/457525a09e802c74228904486f54a293_400x540.png)](../../../profile/img/profile_settings_dropdown.png) 2. 導航至**GPG 密鑰**標簽,然后將您的*公共*密鑰粘貼到"密鑰"框中. [![Paste GPG public key](https://img.kancloud.cn/e8/a4/e8a48454cb386e58927e0eb25de39077_942x212.png)](img/profile_settings_gpg_keys_paste_pub.png) 3. 最后,單擊**添加鍵**將其添加到 GitLab. 您將能夠看到其指紋,相應的電子郵件地址和創建日期. [![GPG key single page](https://img.kancloud.cn/d8/d2/d8d2e67541e9e625600ff52ea36cabcd_929x62.png)](img/profile_settings_gpg_keys_single_key.png) ## Associating your GPG key with Git[](#associating-your-gpg-key-with-git "Permalink") [創建 GPG 密鑰](#generating-a-gpg-key)并將其[添加到您的帳戶之后](#adding-a-gpg-key-to-your-account) ,是時候告訴 Git 使用哪個密鑰了. 1. 使用以下命令列出您剛剛創建的私密 GPG 密鑰: ``` gpg --list-secret-keys --keyid-format LONG <your_email> ``` 將`<your_email>`替換為您在上面輸入的電子郵件地址. 2. 復制以`sec`開頭的 GPG 密鑰 ID. 在以下示例中,即`30F2B65B9246B6CA` : ``` sec rsa4096/30F2B65B9246B6CA 2017-08-18 [SC] D5E4F29F3275DC0CDA8FFC8730F2B65B9246B6CA uid [ultimate] Mr. Robot <your_email> ssb rsa4096/B7ABC0813E4028C0 2017-08-18 [E] ``` 3. 告訴 Git 使用該密鑰對提交進行簽名: ``` git config --global user.signingkey 30F2B65B9246B6CA ``` 用您的 GPG 密鑰 ID 替換`30F2B65B9246B6CA` . 4. (可選)如果 Git 使用`gpg`并且出現諸如`secret key not available`或`gpg: signing failed: secret key not available` ,請運行以下命令更改為`gpg2` : ``` git config --global gpg.program gpg2 ``` ## Signing commits[](#signing-commits "Permalink") [創建 GPG 密鑰](#generating-a-gpg-key)并將其[添加到您的帳戶之后](#adding-a-gpg-key-to-your-account) ,您可以開始對提交進行簽名: 1. 像以前一樣提交,唯一的區別是添加了`-S`標志: ``` git commit -S -m "My commit msg" ``` 2. 詢問時輸入 GPG 密鑰的密碼. 3. 推送至 GitLab 并檢查您的提交[是否已通過驗證](#verifying-commits) . 如果您不想在每次提交時都鍵入`-S`標志,則可以告訴 Git 自動簽名您的提交: ``` git config --global commit.gpgsign true ``` ## Verifying commits[](#verifying-commits "Permalink") 1. 在項目或[合并請求中](../../merge_requests/index.html) ,導航到" **提交"**選項卡. 簽名的提交將顯示包含" Verified"或" Unverified"的徽章,具體取決于 GPG 簽名的驗證狀態. [![Signed and unsigned commits](https://img.kancloud.cn/7e/66/7e66a1435013404841630afe6e514a02_1268x635.png)](img/project_signed_and_unsigned_commits.png) 2. 通過單擊 GPG 徽章,將顯示簽名的詳細信息. [![Signed commit with verified signature](https://img.kancloud.cn/5f/70/5f7025180e9427958882b42f1b8983db_308x266.png)](img/project_signed_commit_verified_signature.png) [![Signed commit with verified signature](https://img.kancloud.cn/35/32/353201946357a77c1f73769be7617388_322x176.png)](img/project_signed_commit_unverified_signature.png) ## Revoking a GPG key[](#revoking-a-gpg-key "Permalink") 撤消密鑰將**取消驗證**已簽名的提交. 使用此密鑰驗證的提交將變為未驗證狀態. 撤銷此密鑰后,將來的提交也將保持不變. 如果您的密鑰已被盜用,則應使用此操作. 撤銷 GPG 密鑰: 1. 點擊右上角的頭像,然后轉到**"設置"** . 2. 導航到**GPG 鍵**標簽. 3. 單擊您要刪除的 GPG 鍵**旁邊的撤消** . ## Removing a GPG key[](#removing-a-gpg-key "Permalink") 刪除密鑰**不會**取消**驗證**已簽名的提交. 使用此密鑰驗證的提交將保持驗證狀態. 刪除此密鑰后,只有未按下的提交才會保持未驗證狀態. 要取消驗證已簽名的提交,您需要從您的帳戶中[撤銷關聯的 GPG 密鑰](#revoking-a-gpg-key) . 要從您的帳戶中刪除 GPG 密鑰,請執行以下操作: 1. 點擊右上角的頭像,然后轉到**"設置"** . 2. 導航到**GPG 鍵**標簽. 3. 單擊您要刪除的 GPG 密鑰旁邊的垃圾桶圖標. ## Rejecting commits that are not signed[](#rejecting-commits-that-are-not-signed-premium "Permalink") 您可以將您的項目配置為拒絕不是通過[推送規則進行](../../../../push_rules/push_rules.html) GPG 簽名的提交. ## GPG signing API[](#gpg-signing-api "Permalink") 了解如何[通過 API 通過提交獲取 GPG 簽名](../../../../api/commits.html#get-gpg-signature-of-a-commit) . ## Further reading[](#further-reading "Permalink") 有關 GPG 的更多詳細信息,請參見: * [Git Tools - Signing Your Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work) * [Managing OpenPGP Keys](https://riseup.net/en/security/message-security/openpgp/gpg-keys) * [OpenPGP Best Practices](https://riseup.net/en/security/message-security/openpgp/best-practices) * [Creating a new GPG key with subkeys](https://www.void.gr/kargig/blog/2013/12/02/creating-a-new-gpg-key-with-subkeys/) (advanced)
                  <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>

                              哎呀哎呀视频在线观看