入門指南

SSH 金鑰

將您的 SSH 公開金鑰上傳至 VulnCheck 平台,即可從 git.vulncheck.com 複製(clone)git 儲存庫。

我們所有的 git 儲存庫皆可透過 SSH 金鑰存取。本指南將逐步說明如何產生新的 SSH 金鑰,並將其加入您的 VulnCheck 帳號。

產生新的 SSH 金鑰

您需要產生新的 SSH 金鑰並將其加入您的 VulnCheck 帳號。請依照以下步驟操作:

開啟終端機視窗

決定要使用的演算法,然後貼上以下文字,並替換為您的電子郵件地址

ssh-keygen -t ed25519 -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):

出現如下提示時,輸入一組安全的密語(passphrase)

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

加入新的 SSH 金鑰

產生 SSH 金鑰後,您需要將其加入您的 VulnCheck 帳號。請依照以下步驟操作:

測試您的 SSH 金鑰

將 SSH 金鑰加入 VulnCheck 帳號後,您可以透過複製儲存庫來進行測試。以下是幾種可選的方式:

使用 SSH 指令

您可以指定 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 agent,如此一來每次複製儲存庫時就不必再指定 SSH 指令。請依照以下步驟操作:

將新的金鑰加入 ssh-agent

ssh-add ./sshkey

接著執行以下指令,確認您的金鑰已加入

ssh-add -l

這應會印出新金鑰的指紋。您可以將此指紋與權杖區段中的 SSH 金鑰清單進行比對,確認是否為正確的金鑰。