【问题标题】:Git Bash - ssh-keygen not working (quits before generating RSA key pair)Git Bash - ssh-keygen 不工作(在生成 RSA 密钥对之前退出)
【发布时间】:2019-07-02 20:20:21
【问题描述】:

它与 Eclipse 默认的 git 扩展配合得很好,我可以使用它进行每一个操作,我什至可以生成 RSA 密钥。

但是当我使用 git bash 访问 git remote 时,我得到了这个错误:

The authenticity of host '[hostname]:PORT ([IP Address]:PORT)' can't be established.
RSA key fingerprint is SHA256:U...M.
Are you sure you want to continue connecting (yes/no)? fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

然后我删除了现有的 RSA 密钥并尝试生成新的 RSA 密钥对及其启动,然后在完成前退出。

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/userName/.ssh/id_rsa):
userName@example MINGW64 ~/git/path (branch name):

我还尝试使用 GIT GUI 生成新的 RSA 密钥,但出现以下错误

error writing "stdout": broken pipe
error writing "stdout": broken pipe
    while executing
"puts $::answer"
    (procedure "finish" line 9)
    invoked from within
"finish"
    invoked from within
".b.ok invoke"
    ("uplevel" body line 1)

提前致谢。

【问题讨论】:

  • 我认为它具有足够的描述性并且属于编程范畴,这不是一个简单的编码问题,我可以提供足够的可重现代码。我在这个网站上看到了关于 Git 和 ssh 的各种问题。我不明白为什么有人反对它?
  • @OmChoudhary 我的回答是否足以解决您的问题?

标签: bash git ssh rsa


【解决方案1】:

如果您使用的是最新版本的 Git(2.19.2 或更高版本),请确保生成 PEM 私有 SSH 密钥,而不是 OPENSSH 密钥。
见“Jenkins: what is the correct format for private key in Credentials

用途:

ssh-keygen -m PEM -t rsa -P "" -f afile

然后再试一次你的 git push,从一个简单的 CMD(不需要 bash),使用 simplified PATH:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%

【讨论】:

    猜你喜欢
    • 2014-10-22
    • 2020-08-06
    • 2021-09-10
    • 1970-01-01
    • 2019-05-05
    • 2021-05-13
    • 2013-09-02
    相关资源
    最近更新 更多