我們所有的 git 儲存庫皆可透過 SSH 金鑰存取。本指南將逐步說明如何產生新的 SSH 金鑰,並將其加入您的 VulnCheck 帳號。
您需要產生新的 SSH 金鑰並將其加入您的 VulnCheck 帳號。請依照以下步驟操作:
ssh-keygen -t ed25519 -C "your_email@example.com"
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
這會以您提供的電子郵件作為標籤,建立新的 SSH 金鑰。畫面上應會顯示類似以下的訊息:
Generating public/private ALGORITHM key pair.
當系統提示「Enter a file in which to save the key」時,您可以按 Enter 接受預設的檔案位置。請注意,若您先前已建立過 SSH 金鑰,ssh-keygen 可能會要求您覆寫另一把金鑰;在這種情況下,建議您建立自訂名稱的 SSH 金鑰。做法是輸入預設的檔案位置,並將 id_ssh_keyname 替換為您自訂的金鑰名稱。畫面上應會顯示類似以下的訊息:
Enter a file in which to save the key (/c/Users/USERNAME/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
產生 SSH 金鑰後,您需要將其加入您的 VulnCheck 帳號。請依照以下步驟操作:
將 SSH 金鑰加入 VulnCheck 帳號後,您可以透過複製儲存庫來進行測試。以下是幾種可選的方式:
您可以指定 git 在執行 git clone 時所使用的 SSH 指令。請依照以下步驟操作:
GIT_SSH_COMMAND='ssh -i ./sshkey' \
git clone git@git.vulncheck.com:bitbucket.org/mburr/cve-2015-7547.git
Cloning into 'cve-2015-7547'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 18 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (18/18), 50.11 KiB | 1.39 MiB/s, done.
您可以將 SSH 金鑰加入 SSH agent,如此一來每次複製儲存庫時就不必再指定 SSH 指令。請依照以下步驟操作:
ssh-add ./sshkey
ssh-add -l
這應會印出新金鑰的指紋。您可以將此指紋與權杖區段中的 SSH 金鑰清單進行比對,確認是否為正確的金鑰。