Skip to main content
  1. Learn center
  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 路径关联的 origin 远程将添加到远程连接此存储库的列表中。单击“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