首页 > 解决方案 > 如何将已生成的 SSH 密钥添加到 git bash?

问题描述

我有一个 SSH 密钥保存在D:/keys folder. 我想将它添加到我的 git bash 中。我找到的所有教程都是如何使用 gitbash 生成 SSH 密钥并将其加载到 github/gitlab。我使用 puttygen 生成了我的 SSH 密钥。现在我想将它添加到我的 git bash 中,以便我可以从远程克隆存储库。我怎样才能做到这一点?

标签: bashgitsshputtyssh-keys

解决方案


在 Windows 上,您可能需要像这样启动 ssh 代理

# start the ssh-agent in the background
$ eval $(ssh-agent -s)
> Agent pid 59566

将您的 SSH 私钥添加到 ssh-agent。如果您使用不同的名称创建了密钥,或者如果您要添加具有不同名称的现有密钥,请将命令中的 id_rsa 替换为您的私钥文件的名称。

$ ssh-add <path/to/key>

在“将您的 SSH 密钥添加到 ssh-agent”下从此处获取此信息: https ://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to- the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent


推荐阅读