【问题标题】:Generating a gitlab ssh key from windows从 windows 生成 gitlab ssh 密钥
【发布时间】:2017-04-30 03:30:33
【问题描述】:

我已尝试关注this guide 生成 ssh 密钥以使用 gitlab。

在我知道是否应该生成密钥之前,我必须检查是否已经存在这样的密钥:

type %userprofile%\.ssh\id_rsa.pub

如果它这么说,那么我必须生成密钥:

the system cannot find the path specified

下一步是什么?因为如果这是我收到的信息,指南没有说任何内容。

编辑:我试过了

ssh-keygen -t rsa -C "email@example.com"

我明白了

'ssh-keygen' is not recognized as an internal or external command, 
operable program or batch file.

编辑 2:我在 Windows 上。

【问题讨论】:

  • 试试这个ssh-keygen -t rsa -C "email@example.com"
  • @sajibkhan 我为此命令添加了编辑
  • 从 OP 命令中的路径和来自 shell 的错误消息来看,我打赌 OP 在 Windows 上。 ssh-keygen 通常是一个 *nix 工具。
  • 确保您已经安装了git。那就试试ssh-keygen ...
  • ssh-keygen 不是git 的一部分。

标签: ssh cmd gitlab


【解决方案1】:

如果你安装了 git for windows,在 windows 上运行 git-gui。然后点击Help,再点击Show Ssh Key,再点击Generate Key。

当您使用它时,复制到剪贴板,然后转到您的 Gitlab 帐户页面并将 SSH 密钥添加到您的 Gitlab 帐户的 ssh 设置中。

【讨论】:

  • 完美,谢谢!我尝试了很长时间让它与 Puttygen 一起使用,但这显然给了我错误的密钥。
  • 天哪,这让我很生气这是多么简单。谢谢。
【解决方案2】:

这里的目的是让%userprofile% 成为您系统中存在的环境变量,其中包含您实际用户的主目录。请检查为什么您的系统上未设置此环境变量并修复它,或者为了快速修复,请将上述命令中的 %userprofile% 替换为您实际用户的主目录。

【讨论】:

  • 替换成 in 而不是写 %userprofile%C:\Users\example?
  • @Hadarsi320 是的,假设 example 是您的用户名。
  • 这个人实际上是在想一个 type 命令会产生一些东西。不,如果它已经存在,它将使其显示在屏幕上。但是 dos 中的 type 命令就像 unix 中的 cat 命令一样,它只是从一个地方读取并将输出放在另一个地方,比如控制台(屏幕)。
【解决方案3】:

如果你想在不依赖git的情况下在windows中创建密钥,你可以去Apps & Features > Optional Features > OpenSSH client (install)

完成后,您将可以使用 keygen 命令。请注意,需要指定位(-b),因为 gitlab 不接受默认大小。

看起来像这样:ssh-keygen -b 2048 -t rsa -C "email@example.com"

【讨论】:

    猜你喜欢
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 2020-03-01
    • 2015-03-26
    • 2011-07-27
    • 2013-03-17
    相关资源
    最近更新 更多