git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.39k stars 2.54k forks source link

[git bash][ssh] unable to accessing a remote hg repo through ssh #428

Closed nanake closed 9 years ago

nanake commented 9 years ago

In Git-1.9.5-preview20150319, I can access remote hg repo.

Ake@SIGMATAUPI /D/dev/custume $ hg pull pulling from ssh://hg@bitbucket.org/nanake/custume Enter passphrase for key '/c/Users/Ake/.ssh/bitbucket/id_rsa': searching for changes no changes found

When I upgraded to Git-2.5.3-32-bit.

I can access to git repo.

Ake@sigmataupi MINGW32 /d/dev/sandbox (master) $ git pull Enter passphrase for key '/c/Users/Ake/.ssh/bitbucket/id_rsa': Already up-to-date.

I cannot access remote hg repo.

Ake@sigmataupi MINGW32 /d/dev/custume $ hg pull pulling from ssh://hg@bitbucket.org/nanake/custume remote: Permission denied (publickey). abort: no suitable response from remote hg!

Ake@sigmataupi MINGW32 /d/dev/custume $ hg in remote: Permission denied (publickey). abort: no suitable response from remote hg!

but I can ssh -t

Ake@sigmataupi MINGW32 /d/dev/custume $ ssh -T hg@bitbucket.org Enter passphrase for key '/c/Users/Ake/.ssh/bitbucket/id_rsa': logged in as nanake. ` You can use git or hg to connect to Bitbucket. Shell access is disabled.`

github:

Ake@sigmataupi MINGW32 /d/dev/custume $ ssh -T git@github.com Enter passphrase for key '/c/Users/Ake/.ssh/github/id_rsa': Hi nanake! You've successfully authenticated, but GitHub does not provide shell access.

:heart_eyes::heart_eyes: Please support access to hg repo via ssh again like git 1.9.5 :heart_eyes::heart_eyes:

I'm on windows 10. Install from installer. Options are:

  1. use git and optional unix tools from windows command prompt
  2. checkout as-is, commit unix style line endings

$PATH from git bash Ake@sigmataupi MINGW32 ~ $ echo $PATH /c/Users/Ake/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin:/mingw32/bin:/usr/bin:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program Files/ThinkPad/Bluetooth Software:/c/Python34:/c/Python34/Scripts:/c/ProgramData/chocolatey/bin:/c/Program Files/OpenVPN/bin:/c/Program Files/nodejs:/cmd:/mingw32/bin:/usr/bin:/c/Tcl/bin:/c/Program Files/Mercurial:/c/Program Files/EditPlus 3:/c/Program Files/Sublime Text 3:/c/platform-tools:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/Program Files/ThinkPad/Bluetooth Software:/c/Python34:/c/Python34/Scripts:/c/ProgramData/chocolatey/bin:/c/Program Files/OpenVPN/bin:/c/Program Files/nodejs:/cmd:/mingw32/bin:/usr/bin:/c/cmdtools/zip:/c/cmdtools/sqlite:/c/Users/Ake/AppData/Roaming/npm:/c/Program Files/MacType:/usr/bin/vendor_perl:/usr/bin/core_perl

%PATH% from git cmd C:\Users\Ake>echo %PATH% C:\Program Files\Git\cmd;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Python34;C:\Python34\Scripts;C:\ProgramData\chocolatey\bin;C:\Program Files\OpenVPN\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw32\bin;C:\Program Files\Git\usr\bin;C:\Tcl\bin;C:\Program Files\Mercurial;C:\Program Files\EditPlus 3;C:\Program Files\Sublime Text 3;C:\platform-tools;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Python34;C:\Python34\Scripts;C:\ProgramData\chocolatey\bin;C:\Program Files\OpenVPN\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw32\bin;C:\Program Files\Git\usr\bin;C:\cmdtools\zip;C:\cmdtools\sqlite;C:\Users\Ake\AppData\Roaming\npm;C:\Program Files\MacType

$HOME from git bash Ake@sigmataupi MINGW32 ~ $ echo $HOME /c/Users/Ake

%HOME% from git cmd C:\Users\Ake

dscho commented 9 years ago

In your ~/.ssh/config, could you set LogLevel DEBUG3 for the BitBucket host?

dscho commented 9 years ago

Oh, I think I know what it is... It is Python not being able to handle the mintty console window. To verify, could you test both of the following two options?

  1. winpty hg pull
  2. reinstall with the "default Windows console" instead of the mintty one, then run hg pull
nanake commented 9 years ago
  1. winpty hg pull

$ winpty hg pull pulling from ssh://hg@bitbucket.org/nanake/custume remote: Permission denied (publickey). abort: no suitable response from remote hg!

  1. reinstall with the "default Windows console" instead of the mintty one, then run hg pull

It's the same as 1. remote: Permission denied (publickey). abort: no suitable response from remote hg!

In your ~/.ssh/config, could you set LogLevel DEBUG3 for the BitBucket host?

Nothing happened after running hg pull. I wait about 5 mins and have to terminate git bash. $ hg pull pulling from ssh://hg@bitbucket.org/nanake/custume

I tried to add LogLevel DEBUG3 to the other hosts and still can't run hg pull, hg in, hg out.

but I can git pull with LogLevel DEBUG3

$ git pull debug2: ssh_connect: needpriv 0 debug1: Connecting to bitbucket.org [131.103.20.167] port 22. debug1: Connection established. debug1: identity file /c/Users/Ake/.ssh/bitbucket/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Ake/.ssh/bitbucket/id_rsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to bitbucket.org:22 as 'git' debug3: hostkeys_foreach: reading file "/c/Users/Ake/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /c/Users/Ake/.ssh/known_hosts:2 debug3: load_hostkeys: loaded 1 keys from bitbucket.org debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519 debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib@openssh.com debug2: kex_parse_kexinit: none,zlib@openssh.com debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug1: kex: server->client aes128-ctr umac-64@openssh.com none debug1: kex: client->server aes128-ctr umac-64@openssh.com none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent debug1: got SSH2_MSG_KEX_DH_GEX_GROUP debug2: bits set: 1541/3072 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: got SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A debug3: hostkeys_foreach: reading file "/c/Users/Ake/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /c/Users/Ake/.ssh/known_hosts:2 debug3: load_hostkeys: loaded 1 keys from bitbucket.org debug3: hostkeys_foreach: reading file "/c/Users/Ake/.ssh/known_hosts" debug3: record_hostkey: found key type RSA in file /c/Users/Ake/.ssh/known_hosts:5 debug3: load_hostkeys: loaded 1 keys from 131.103.20.167 debug1: Host 'bitbucket.org' is known and matches the RSA host key. debug1: Found key in /c/Users/Ake/.ssh/known_hosts:2 debug2: bits set: 1539/3072 debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /c/Users/Ake/.ssh/bitbucket/id_rsa (0x2005a2b0), explicit debug1: Authentications that can continue: publickey debug3: start over, passed a different list publickey debug3: preferred publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /c/Users/Ake/.ssh/bitbucket/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Remote: Forced command: conq username:nanake debug1: Remote: Port forwarding disabled. debug1: Remote: X11 forwarding disabled. debug1: Remote: Agent forwarding disabled. debug1: Remote: Pty allocation disabled. debug1: Server accepts key: pkalg ssh-rsa blen 1047 debug2: input_userauth_pk_ok: fp SHA256:7WfFChcvZr1FdN407wJifmWSkYwqhwiJcK35MOCrhmI debug3: sign_and_send_pubkey: RSA SHA256:7WfFChcvZr1FdN407wJifmWSkYwqhwiJcK35MOCrhmI Enter passphrase for key '/c/Users/Ake/.ssh/bitbucket/id_rsa': debug1: Remote: Forced command: conq username:nanake debug1: Remote: Port forwarding disabled. debug1: Remote: X11 forwarding disabled. debug1: Remote: Agent forwarding disabled. debug1: Remote: Pty allocation disabled. debug1: Authentication succeeded (publickey). Authenticated to bitbucket.org ([131.103.20.167]:22). debug2: fd 4 setting O_NONBLOCK debug2: fd 5 setting O_NONBLOCK debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: ssh_packet_set_tos: set IP_TOS 0x08 debug2: client_session2_setup: id 0 debug1: Sending command: git-upload-pack 'nanake/sandbox.git' debug2: channel 0: request exec confirm 1 debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel 0: rcvd adjust 2097152 debug2: channel_input_status_confirm: type 99 id 0 debug2: exec request accepted on channel 0 debug2: channel 0: read<=0 rfd 4 len 0 debug2: channel 0: read failed debug2: channel 0: close_read debug2: channel 0: input open -> drain debug2: channel 0: ibuf empty debug2: channel 0: send eof debug2: channel 0: input drain -> closed debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0 debug2: channel 0: rcvd eow debug2: channel 0: rcvd eof debug2: channel 0: output open -> drain debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed debug2: channel 0: rcvd close debug3: channel 0: will not send data after close debug2: channel 0: almost dead debug2: channel 0: gc: notify user debug2: channel 0: gc: user detached debug2: channel 0: send close debug2: channel 0: is dead debug2: channel 0: garbage collecting debug1: channel 0: free: client-session, nchannels 1 debug3: channel 0: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

debug3: fd 0 is not O_NONBLOCK debug3: fd 1 is not O_NONBLOCK Transferred: sent 5920, received 4392 bytes, in 1.3 seconds Bytes per second: sent 4471.1, received 3317.0 debug1: Exit status 0 Already up-to-date.

:frowning:

dscho commented 9 years ago

Enter passphrase for key '/c/Users/Ake/.ssh/bitbucket/id_rsa':

I guess it is this line that is most helpful in identifying the problem. Unfortunately, the winpty invocation did not address this (which I hoped it would). But maybe you can still save your use case by setting SSH_ASKPASS:

export DISPLAY=needs-to-be-defined
export SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

(You might need to invoke hg in </dev/null to force the GUI to pop up.)

Does that work for you?

The alternative would be of course to switch to MSys2 altogether and use its own Mercurial which is guaranteed to work fine.

nanake commented 9 years ago

Does that work for you?

That works for me. :smiley: :kissing_heart:

nanake commented 9 years ago

Thank you so much for fixing this. :satisfied:

nanake commented 9 years ago

I tried to apply the patch to etc/profile.d/env.sh on PortableGit-2.5.3 and can confirm it is fixed.

dscho commented 9 years ago

Thank you for your prompt feedback!