git 使用 ssh-keygen 创建 SSH 密钥不会创建 .ssh 文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3076043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:36:11  来源:igfitidea点击:

Creating a SSH key with ssh-keygen does not create the .ssh folder

gitsshmingwversion-controlunfuddle

提问by Charles Ouellet

I am trying to create my public/private rsa key pair with msysgit

我正在尝试使用 msysgit 创建我的公共/私人 rsa 密钥对

I run this command:

我运行这个命令:

ssh-keygen -C "[email protected]" -t rsa

Everything looks fine, I have the message

一切看起来都很好,我收到了消息

Enter file in which to save the key (/c/Users/user/.ssh/id_rsa)

Then I have the confirmation:

然后我得到了确认:

Your public key has been saved in project.pub

But I can't access the folder! It does not exist, it is not even an hidden folder. I don't understand why it does not generate. I am using Windows 7 Ultimate.

但是我无法访问该文件夹!它不存在,它甚至不是一个隐藏文件夹。我不明白为什么它不生成。我正在使用 Windows 7 Ultimate。

回答by VonC

Just created my key without any problem (Seven Ultimate 64bits, msysgit 1.6.5.1.1367.gcd48)

刚刚创建我的密钥没有任何问题(七终极 64 位,msysgit 1.6.5.1.1367.gcd48)

$ ssh-keygen -C "vonc@xxxx" -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/VonC/.ssh/id_rsa):# just press enter
                                                                # to accept the
                                                                # default location
Enter passphrase (empty for no passphrase):                     
Enter same passphrase again:
Your identification has been saved in /c/Users/VonC/.ssh/id_rsa.
Your public key has been saved in /c/Users/VonC/.ssh/id_rsa.pub.
The key fingerprint is:
xx:yy:zz:aa:bb:cc:... vonc@xxxx

With the result:

结果:

VonC@P ~/.ssh
$ ls -alrt
total 10
-rw-r--r--    1 VonC Administ      642 May 23 21:47 known_hosts
drwxr-xr-x   43 VonC Administ    16384 Jun 15 17:01 ..
-rw-r--r--    1 VonC Administ      398 Jun 19 16:14 id_rsa.pub
-rw-r--r--    1 VonC Administ     1675 Jun 19 16:14 id_rsa
drwxr-xr-x    2 VonC Administ        0 Jun 19 16:14 .

Could you check in your bash session what value your $HOMEenvironment variable is set?

你能在你的 bash 会话中检查你的$HOME环境变量设置了什么值吗?

VonC@P ~/.ssh
$ env|grep HOME
HOMEPATH=\Users\VonC
HOME=/c/Users/VonC     # <=== this must be correctly set
HOMEDRIVE=C:

回答by Amit

I had the same problem and I realized I was trying to enter a file name when it asks for the following "Enter file in which to save the key (c/users/user.name/.ssh/id_rsa)"

我遇到了同样的问题,当它要求以下“输入保存密钥的文件(c/users/user.name/.ssh/id_rsa)”时,我意识到我试图输入文件名

Rather just enter nothing and press Enter key to use the default and you will move on.

只需输入任何内容并按 Enter 键即可使用默认值,然后您将继续前进。

回答by Ishara Amarasekera

I faced a similar issue while creating a SSH key and I resolved it this way.

我在创建 SSH 密钥时遇到了类似的问题,我是这样解决的。

When you use ssh-keygen -t rsato generate a SSH key and it prompts you to

当您使用ssh-keygen -t rsa生成 SSH 密钥时,它会提示您

Enter file in which to save the key (/Users/iamarasekera/.ssh/id_rsa):

Enter file in which to save the key (/Users/iamarasekera/.ssh/id_rsa):

Do not give any file name. Instead, just press "Enter" key and go ahead.

不要给出任何文件名。相反,只需按“Enter”键即可。

Then it will create .sshfolder and inside that folder it will generate the 2 files id_rsaand id_rsa.pub.

然后它将创建.ssh文件夹并在该文件夹内生成 2 个文件id_rsaid_rsa.pub.

You will also see the message Created directory '/<path to your current folder>/.ssh'.on your command prompt.

您还将Created directory '/<path to your current folder>/.ssh'.在命令提示符上看到该消息。

Next, it will prompt you toEnter passphraseand you better not skip it.

接下来,它会提示你Enter passphrase,你最好不要跳过它。

Check this out for your reference.

看看这个以供您参考。

enter image description here

在此处输入图片说明

Note: If you enter a file name when it prompts you to enter a file name to save the key it creates 2 file as <filename>and <filename>.pubinside the directory where you are currently located without creating a .ssh folder.

Note:如果您在提示您输入文件名以保存密钥时输入文件名,则会在您当前所在的目录中创建 2 个文件,<filename><filename>.pub不会创建 .ssh 文件夹。

Hope this helps.

希望这可以帮助。

回答by Galivan

If you already have a key called "id_rsa" and you want to save a new one in a different name, you need to provide the whole path, if I understood it. So when it asks:

如果您已经有一个名为“id_rsa”的密钥并且您想以不同的名称保存一个新的密钥,那么您需要提供整个路径(如果我理解的话)。所以当它问:

Enter file in which to save the key (/c/Users/myname/.ssh/id_rsa):

You can type /c/Users/myname/.ssh/new_keyand it will be created (I just tested).

您可以输入/c/Users/myname/.ssh/new_key,它将被创建(我刚刚测试过)。

回答by Aparna

This worked for me.. Refer link below

这对我有用..参考下面的链接

http://ekawas.blogspot.co.uk/2007/03/solving-pesky-ssh-issues-in-cygwin.html

http://ekawas.blogspot.co.uk/2007/03/solving-pesky-ssh-issues-in-cygwin.html

edit the passwd file in c:/cygwin64/etc. Open it with wordpad

编辑 c:/cygwin64/etc 中的 passwd 文件。用写字板打开

edit home/YOUR_NAME to /cygdrive/c/Documents and Settings/YOUR_NAME

将 home/YOUR_NAME 编辑为 /cygdrive/c/Documents and Settings/YOUR_NAME