简体   繁体   English

使用 Git for Windows 的 SSH 失败

[英]SSH Failure using Git For Windows

I'm using Git For Windows (not msys or GitHub) in my build server scripts.我在我的构建服务器脚本中使用 Git For Windows(不是 msys 或 GitHub)。 We have a self-hosted BitBucket repository with an SSH access key configured.我们有一个配置了 SSH 访问密钥的自托管 BitBucket 存储库。 I'm trying to do an initial clone in my build scripts via the command line and it is failing with an SSH error/我正在尝试通过命令行在我的构建脚本中进行初始克隆,但由于 SSH 错误而失败/

Here is my environment:这是我的环境:

  • Windows Server 2012视窗服务器 2012
  • Git For Windows 1.9.4适用于 Windows 1.9.4 的 Git
  • SSH key stored in %USERPROFILE%\\.ssh SSH 密钥存储在 %USERPROFILE%\\.ssh 中
  • .ssh\\config points to proper SSH key for my git server domain .ssh\\config 指向我的 git 服务器域的正确 SSH 密钥
  • my server is in my known_hosts file我的服务器在我的known_hosts文件中
  • SysInternals ProcMon shows that the ssh key is being checked during the clone operation SysInternals ProcMon 显示在克隆操作期间正在检查 ssh 密钥
  • The same clone operation works using the Git Bash window that comes with Git for Windows.使用 Git for Windows 附带的 Git Bash 窗口可以执行相同的克隆操作。 So this rules out an invalid key (I believe)所以这排除了无效的密钥(我相信)

Here is the Loglevel DEBUG3 logging from SSH during the clone operation:这是克隆操作期间来自 SSH 的 Loglevel DEBUG3 日志记录:

 [exec] debug3: send packet: type 30
 [exec] debug1: sending SSH2_MSG_KEX_ECDH_INIT
 [exec] debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
 [exec] debug3: receive packet: type 31
 [exec] debug1: Server host key: ssh-rsa SHA256:K7Y..

 [exec] debug3: put_host_port: [x.x.x.x]:7999
 [exec] debug3: put_host_port: [xxxmyserverxxx.local]:7999
 [exec] debug1: checking without port identifier
 [exec] debug1: read_passphrase: can't open /dev/tty: No such device or address
 [exec] Host key verification failed.
 [exec] fatal: Could not read from remote repository.
 [exec]
 [exec] Please make sure you have the correct access rights
 [exec] and the repository exists.

I can't tell if the "can't open /dev/tty" issue is the real deal breaker.我不知道“无法打开 /dev/tty”问题是否是真正的交易破坏者。 I don't even know what /dev/tty would equate to inside of a Windows command window.我什至不知道 /dev/tty 在 Windows 命令窗口中等同于什么。

What's more frustrating is this exact type of operation succeeds on another repo I use with the same SSH key pair.更令人沮丧的是,这种确切类型的操作在我使用相同 SSH 密钥对的另一个存储库上成功。 I can see no difference in the configuration我看不出配置有什么不同

read_passphrase: can't open /dev/tty: No such device or address is your deal breaker here. read_passphrase: can't open /dev/tty: No such device or address是你的交易破坏者。 Git needs to get the password of your ssh key but cannot since it has no access to the tty (stdin). Git 需要获取 ssh 密钥的密码,但不能,因为它无法访问 tty (stdin)。 Are you running your git command from the Git Bash or from some other terminal?您是从 Git Bash 还是从其他终端运行 git 命令?

As a workaround, you can create a passwordless ssh key and use that one instead.作为一种解决方法,您可以创建一个无密码的 ssh 密钥并改用该密钥。 To get that working, in your Git Bash home directory, set something similar to this example:要使其正常工作,请在您的 Git Bash 主目录中设置类似于此示例的内容:

$ ssh-keygen -b 4096 -t rsa -N "" -f "${HOME}/.ssh/id_rsa_passwordless"

$ cat <<EOF >>.ssh/config
Host github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_passwordless
EOF

Of course, it is better that you use an SSH key with a password under Git Bash, but at least you have a workaround.当然,在 Git Bash 下使用带密码的 SSH 密钥会更好,但至少你有一个解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM