如何在Windows中生成一个ssh密钥?

时间:2015-02-06 18:11:51

标签: windows github cmd ssh-keys

我跟随this在Windows 8.1上生成一个ssh密钥,但如果我在要求输入保存密钥的文件时按回车键,我会收到错误could not create the directory '//.ssh'

现在如果不是按回车键,我输入&#34; id_rsa&#34;,然后在执行clip < ~/.ssh/id_rsa.pub后,我得到The system cannot find the path specified

这有什么办法吗?我可以切换到ubuntu,但我想在Windows上执行此操作。

2 个答案:

答案 0 :(得分:2)

找到ssh密钥的最佳方法是:

  1. 在Github中创建一个帐户
  2. 在桌面上下载Github应用程序并使用您的凭据登录
  3. 1分钟后,转到Github网站 - &gt;登录 - &gt;去设置 - &gt;在左侧单击ssh键,在这里您可以找到您的ssh键。

答案 1 :(得分:1)

could not create the directory '//.ssh'

这意味着$ HOME没有被正确定义。首先尝试输入:

export HOME=/c/Users/<yourUsername>

然后ssh-keygen -t rsa -C "$your_email"应该有用。

请注意,如果您在使用git-cmd.bat included in a standard Git for Windows (msysgit)启动的(DOS)shell中键入相同的命令,则会为您设置%HOME% {到%USERPROFILE%),并且相同ssh-keygen -t rsa -C "$your_email"也可以。