简体   繁体   中英

SSH Failure using Git For Windows

I'm using Git For Windows (not msys or GitHub) in my build server scripts. We have a self-hosted BitBucket repository with an SSH access key configured. I'm trying to do an initial clone in my build scripts via the command line and it is failing with an SSH error/

Here is my environment:

  • Windows Server 2012
  • Git For Windows 1.9.4
  • SSH key stored in %USERPROFILE%\\.ssh
  • .ssh\\config points to proper SSH key for my git server domain
  • my server is in my known_hosts file
  • SysInternals ProcMon shows that the ssh key is being checked during the clone operation
  • The same clone operation works using the Git Bash window that comes with Git for Windows. So this rules out an invalid key (I believe)

Here is the Loglevel DEBUG3 logging from SSH during the clone operation:

 [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. I don't even know what /dev/tty would equate to inside of a Windows command window.

What's more frustrating is this exact type of operation succeeds on another repo I use with the same SSH key pair. 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. Git needs to get the password of your ssh key but cannot since it has no access to the tty (stdin). Are you running your git command from the Git Bash or from some other terminal?

As a workaround, you can create a passwordless ssh key and use that one instead. To get that working, in your Git Bash home directory, set something similar to this example:

$ 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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