Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git 的指令和設定
  6. SSH 連線設定
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

SSH 連線設定


設定 SSH 連線 (Windows)

前往開始選單 > All Programs > 開啟 TortoiseGit 並啟動 Putty Key Generator。

Open TortoiseGit items and run Puttygen

單擊「Generate」並將滑鼠游標移動到紅色框內,直到進度條完成。這將隨機生成一個密鑰。

Until the progress bar reaches the right corner, you move the mouse with the red-framed area

密鑰生成完成後,您將看到以下顯示。單擊「Save private key」並儲存.ppk檔案。

Save the ppk file by clicking the "Save private key" button.

您以後可以透過將.ppk檔案加載到 Putty Key Generator 中,再次查看公鑰。

為了在使用 TortoiseGit 推送時設置 SSH 連線,請右鍵單擊 TortoiseGit,然後選擇「Manage。

If you click TortoiseGit, the following screen will be displayed. Then, click Manage button

在遠端欄中選擇origin,將 SSH 路徑新增到 URL 欄位,並將我們剛才儲存的.ppk檔案路徑新增到 Putty Key 欄位。單擊「Add New/Save」。現在,與 SSH URL 路徑關聯的源遠端將被新增到遠端連接此儲存庫的清單中。單擊「OK」來完成。

Assign the ppk file that you just saved to the Putty authentication, and then click Add New/Save button

設定 SSH 連線 (Mac)

在 application/utility 下開啟終端機,並執行以下指令。

$ ssh-keygen

您將看到以下輸出。您可以選擇輸入此生成的 RSA 密鑰對的 passphrase。

如果您不想設定 passphrase,請按回車鍵繼續。

Generating public/private rsa key pair.
  Enter file in which to save the key (/Users/username/.ssh/id_rsa): <Press Enter key>
  Created directory '/Users/username/.ssh'.
  Enter passphrase (empty for no passphrase): <Input passphrase>
  Enter same passphrase again: <Please enter the same passphrase again>
  Your identification has been saved in /Users/username/.ssh/id_rsa.
  Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
  The key fingerprint is:
  57:15:3c:ca:f2:dc:27:6d:c2:9a:88:d0:70:cf:8d:31 username@username-example-device
  The key's randomart image is:
  +--[ RSA 2048]----+
  |             .o. |
  |             .o  |
  |           ... . |
  |      . . E.o    |
  |       +So.O o . |
  |      . ..+ + = +|
  |       . . . o = |
  |        . . o    |
  |                 |
  +-----------------+

您可以使用以下指令查看 SSH 公鑰。

$ cat ~/.ssh/id_rsa.pub

輸出範例

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkkJvxyDVh9a+zH1f7ZQq/JEI79dVjDSG
  4RzttQwfK+sgWEr0aAgfnxdxQeDKxIxqI1SwyTY8oCcWzvpORuPqwbc7UWWPcCvbQ3jlEdN
  5jvwKM82hincEWwI3wzcnVg2Mn8dH86b5m6REDzwRgozQ3lqrgwGVlTvkHDFs6H0b/1PSrM
  XGppOP/QXGEVhZ6Hy4m3b1wMjjrbYwmWIeYklgoGHyrldhAaDYc33y7aUcRyFyq5DubtsLn
  2oj4K+1q36iviCHxCOri0FDmn2dzylRCI4S+A2/P7Y7rVfdT+8OWYKCBUs8lfjujghEtejq
  Qmj9ikyGTEAW1zQCN7hVwYdjL hoge@hoge.local

將此密鑰複製,並粘貼到遠端儲存庫設定中。

設定 SSH 連線 (Console)

執行以下指令。

$ ssh-keygen

您將看到以下輸出。您可以選擇輸入此生成的 RSA 密鑰對的 passphrase。如果您不想設定 passphrase,請按回車鍵。

Generating public/private rsa key pair.
  Enter file in which to save the key (/Users/username/.ssh/id_rsa): <Press Enter key>
  Created directory '/Users/username/.ssh'.
  Enter passphrase (empty for no passphrase): <Input passphrase>
  Enter same passphrase again: <Please enter the same passphrase again>
  Your identification has been saved in /Users/username/.ssh/id_rsa.
  Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
  The key fingerprint is:
  57:15:3c:ca:f2:dc:27:6d:c2:9a:88:d0:70:cf:8d:31 username@username-example-device
  The key's randomart image is:
  +--[ RSA 2048]----+
  |             .o. |
  |             .o  |
  |           ... . |
  |      . . E.o    |
  |       +So.O o . |
  |      . ..+ + = +|
  |       . . . o = |
  |        . . o    |
  |                 |
  +-----------------+

您可以使用以下指令查看 SSH 公鑰。

$ cat ~/.ssh/id_rsa.pub

輸出範例

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkkJvxyDVh9a+zH1f7ZQq/JEI79dVjDSG
  4RzttQwfK+sgWEr0aAgfnxdxQeDKxIxqI1SwyTY8oCcWzvpORuPqwbc7UWWPcCvbQ3jlEdN
  5jvwKM82hincEWwI3wzcnVg2Mn8dH86b5m6REDzwRgozQ3lqrgwGVlTvkHDFs6H0b/1PSrM
  XGppOP/QXGEVhZ6Hy4m3b1wMjjrbYwmWIeYklgoGHyrldhAaDYc33y7aUcRyFyq5DubtsLn
  2oj4K+1q36iviCHxCOri0FDmn2dzylRCI4S+A2/P7Y7rVfdT+8OWYKCBUs8lfjujghEtejq
  Qmj9ikyGTEAW1zQCN7hVwYdjL hoge@hoge.local

將此密鑰複製,並粘貼到遠端儲存庫設定中。

將 SSH 公鑰註冊到 Backlog

用您可以存取 Git 儲存庫的帳戶使用者名稱登錄到 Backlog。登錄後,單擊「Personal Settings」。

Click "Personal setting"

單擊「Register SSH public key」。

Click "Register SSH public key"

將 SSH 公鑰粘貼到文本區域,然後單擊「Submit」。

Paste the content of SSH public key and click "Register" button

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life