我刚刚开始了一个 Git 教程,但我遇到了死胡同:我尝试生成一个 rsa 密钥部分,但它失败了。我这样做了,在 git bash 中:
ssh-keygen -t rsa -C "myemail@myemail.com"
我得到了这个:
Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa): enter passphrase: enter same passphrase again: open /c/Users/Eva/.ssh/id_rsa failed: no such file or directory. Saving the key failed:/c/Users/Eva/.ssh/id_rsa.
我尝试保存在不同的文件夹中,一切正常。但现在我执行命令ssh -T git@github.com ,它给了我错误permisson denied (publickey).
ssh -T git@github.com
permisson denied (publickey).
如果您更喜欢使用 GUI 来创建密钥
有关上述步骤的 putty gen 演练,请参阅http://ask-leo.com/how_do_i_create_and_use_public_keys_with_ssh.html
如果您使用的是 Windows,则 ssh-keygen 的 unix 样式默认路径有问题。
在第 2 行它说Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):。括号中的完整文件名是默认值,显然 Windows 无法访问这样的文件。如果您键入 Windows 等效项 ( c:\Users\Eva\.ssh\id_rsa),它应该可以工作。
Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):
c:\Users\Eva\.ssh\id_rsa
在运行此之前,您还需要创建文件夹。您可以通过运行mkdir c:\Users\Eva\.ssh或创建文件夹“.ssh”来执行此操作。从文件资源管理器(请注意末尾的第二个点,它将自动删除,并且需要创建一个开头有一个点的文件夹)。
mkdir c:\Users\Eva\.ssh
c:\Users\Administrator\.ssh>ssh-keygen -t rsa -C "myemail@myemail.com" Generating public/private rsa key pair. Enter file in which to save the key (/home/Administrator/.ssh/id_rsa): C:\Users\Administrator\.ssh\id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\Administrator\.ssh\id_rsa. Your public key has been saved in C:\Users\Administrator\.ssh\id_rsa.pub. The key fingerprint is: ... myemail@myemail.com The key's randomart image is:...`
我知道这是一个旧线程,但我认为答案可能对其他人有所帮助。