首页 > 解决方案 > 使用 git bash 在 Windows 中获取文件错误

问题描述

我在 Windows 中使用 git bash 将 ssh 密钥存储在 ssh 代理中并遇到此错误。

$ ssh-add ~/.ssh/id_rsa
/c/Users/abhis/.ssh/id_rsa: No such file or directory

然后我删除了 .ssh/id_rsa 并用密钥文件的名称保存了它。有效。

$ ssh-add ~/[myfilename]
Identity added: [My Folder name] (email id)

为什么这行得通。

标签: bashgitgithubsshgitlab-ci

解决方案


ssh-add询问密钥的文件名。该错误意味着程序找不到名为~/.ssh/id_rsa.

当您提供ssh-add密钥文件的实际文件名时,它按预期工作。

为了ssh-add ~/.ssh/id_rsa工作,您应该将密钥文件放在您的~/.ssh文件夹中并将其命名为id_rsa.


推荐阅读