PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.43k stars 760 forks source link

ssh login with correct public key failed! #1247

Closed hamedsbt closed 4 years ago

hamedsbt commented 6 years ago

"OpenSSH for Windows" version Win64_v7.7.2.0p1_Beta

Server OperatingSystem Win10 x64

Client OperatingSystem Win10 x64

What is failing ssh login with public key

Executed command

ssh gu_sadeh_cashier@127.0.0.1 dir

OR

git clone ssh://gu_sadeh_cashier@127.0.0.1

Actual output fd 5 is not O_NONBLOCK spawning "D:\SFT\OpenSSH_Win64_v7.7.2.0p1_Beta\sshd.exe" "-R" send_rexec_state: entering fd = 8 config len 522 ssh_msg_send: type 0 send_rexec_state: done inetd sockets after dupping: 3, 3 Connection from 127.0.0.1 port 55952 on 127.0.0.1 port 22 Client protocol version 2.0; client software version OpenSSH_for_Windows_7.7 match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000 Local version string SSH-2.0-OpenSSH_for_Windows_7.7 fd 3 setting O_NONBLOCK spawning "D:\SFT\OpenSSH_Win64_v7.7.2.0p1_Beta\sshd.exe" "-y" Network child is on pid 7548 send_rexec_state: entering fd = 6 config len 522 ssh_msg_send: type 0 send_rexec_state: done ssh_msg_send: type 0 ssh_msg_send: type 0 preauth child monitor started list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth] send packet: type 20 [preauth] SSH2_MSG_KEXINIT sent [preauth] receive packet: type 20 [preauth] SSH2_MSG_KEXINIT received [preauth] local server KEXINIT proposal [preauth] KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1 [preauth] host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth] ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth] ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth] MACs ctos: 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 [preauth] MACs stoc: 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 [preauth] compression ctos: none [preauth] compression stoc: none [preauth] languages ctos: [preauth] languages stoc: [preauth] first_kex_follows 0 [preauth] reserved 0 [preauth] peer client KEXINIT proposal [preauth] KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c [preauth] host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa [preauth] ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth] ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth] MACs ctos: 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 [preauth] MACs stoc: 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 [preauth] compression ctos: none [preauth] compression stoc: none [preauth] languages ctos: [preauth] languages stoc: [preauth] first_kex_follows 0 [preauth] reserved 0 [preauth] kex: algorithm: curve25519-sha256 [preauth] kex: host key algorithm: ecdsa-sha2-nistp256 [preauth] kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none [preauth] kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none [preauth] expecting SSH2_MSG_KEX_ECDH_INIT [preauth] receive packet: type 30 [preauth] mm_key_sign entering [preauth] mm_request_send entering: type 6 [preauth] mm_key_sign: waiting for MONITOR_ANS_SIGN [preauth] mm_request_receive_expect entering: type 7 [preauth] mm_request_receive entering [preauth] mm_request_receive entering monitor_read: checking request 6 mm_answer_sign mm_answer_sign: hostkey proof signature 0000019333387500(101) mm_request_send entering: type 7 monitor_read: 6 used once, disabling now send packet: type 31 [preauth] send packet: type 21 [preauth] set_newkeys: mode 1 [preauth] rekey after 134217728 blocks [preauth] SSH2_MSG_NEWKEYS sent [preauth] expecting SSH2_MSG_NEWKEYS [preauth] send packet: type 7 [preauth] receive packet: type 21 [preauth] SSH2_MSG_NEWKEYS received [preauth] set_newkeys: mode 0 [preauth] rekey after 134217728 blocks [preauth] KEX done [preauth] receive packet: type 5 [preauth] send packet: type 6 [preauth] receive packet: type 50 [preauth] userauth-request for user gu_sadeh_cashier service ssh-connection method none [preauth] attempt 0 failures 0 [preauth] mm_getpwnamallow entering [preauth] mm_request_send entering: type 8 [preauth] mm_getpwnamallow: waiting for MONITOR_ANS_PWNAM [preauth] mm_request_receive_expect entering: type 9 [preauth] mm_request_receive entering [preauth] mm_request_receive entering monitor_read: checking request 8 mm_answer_pwnamallow parse_server_config: config reprocess config len 522 checking match for 'User gu_sadeh_cashier Host 127.0.0.1' user gu_sadeh_cashier host 127.0.0.1 addr 127.0.0.1 laddr 127.0.0.1 lport 22 user gu_sadeh_cashier matched 'User gu_sadeh_cashier' at line 93 connection from 127.0.0.1 matched 'Host 127.0.0.1' at line 93 match found reprocess config:94 setting ChrootDirectory E:\DEV\Git_Repos\sadeh_cashier reprocess config:96 setting AllowAgentForwarding no reprocess config:97 setting X11Forwarding no checking match for 'User gu_swac Host 127.0.0.1' user gu_sadeh_cashier host 127.0.0.1 addr 127.0.0.1 laddr 127.0.0.1 lport 22 connection from 127.0.0.1 matched 'Host 127.0.0.1' at line 101 match not found mm_answer_pwnamallow: sending MONITOR_ANS_PWNAM: 1 mm_request_send entering: type 9 monitor_read: 8 used once, disabling now input_userauth_request: setting up authctxt for gu_sadeh_cashier [preauth] mm_inform_authserv entering [preauth] mm_request_send entering: type 4 [preauth] input_userauth_request: try method none [preauth] userauth_finish: failure partial=0 next methods="publickey" [preauth] send packet: type 51 [preauth] mm_request_receive entering monitor_read: checking request 4 mm_answer_authserv: service=ssh-connection, style= monitor_read: 4 used once, disabling now recv - from CB ERROR:10054, io:000001E3EC91C070 [preauth] Connection reset by authenticating user gu_sadeh_cashier 127.0.0.1 port 55952 [preauth] debug1: do_cleanup [preauth] debug1: monitor_read_log: child log fd closed debug3: mm_request_receive entering debug1: do_cleanup debug1: Killing privsep child 7548

other ssh client (putty, bitvise) could connect with same config&ssh key. also if I insert remote config to /.git/config file, it will work too. but I need working clone command.

manojampalam commented 6 years ago

I dont see any indication of server receiving a pubkey auth request. Can you also share client side traces ? (ssh -vvv) ?

hamedsbt commented 6 years ago

I have ENVIRONMENT VARIABLE named: HOME: D:\SFT\OpenSSH_Client_Keys (it contains .ssh/config & .ssh/known_hosts & .ssh/a_key & .ssh/a_key.pub files)

The "config" file contains ssh key full PATH but ssh client does not load config file! why?

ssh -vvv gu_sadeh_cashier@127.0.0.1 dir

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.4 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/config error:2 debug3: Failed to open file:PROGRAMDATA\ssh/ssh_config error:2 debug2: resolve_canonicalize: hostname 127.0.0.1 is address debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22. debug1: Connection established. debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_rsa error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_rsa.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_rsa type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_rsa-cert error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_rsa-cert.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_rsa-cert type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_dsa error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_dsa.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_dsa type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_dsa-cert error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_dsa-cert.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_dsa-cert type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ecdsa error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ecdsa.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_ecdsa type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ecdsa-cert error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ecdsa-cert.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_ecdsa-cert type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ed25519 error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ed25519.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_ed25519 type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ed25519-cert error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_ed25519-cert.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_ed25519-cert type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_xmss error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_xmss.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_xmss type -1 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_xmss-cert error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/id_xmss-cert.pub error:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Hamedsbt/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7 debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_7.7 debug1: match: OpenSSH_for_Windows_7.7 pat OpenSSH* compat 0x04000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to 127.0.0.1:22 as 'gu_sadeh_cashier' debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/known_hosts error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/known_hosts2 error:2 debug3: Failed to open file:PROGRAMDATA\ssh/ssh_known_hosts error:2 debug3: Failed to open file:PROGRAMDATA\ssh/ssh_known_hosts2 error:2 debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent debug3: receive packet: type 20 debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c debug2: host key algorithms: 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,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com debug2: MACs ctos: 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 debug2: MACs stoc: 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 debug2: compression ctos: none debug2: compression stoc: none debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1 debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com debug2: MACs ctos: 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 debug2: MACs stoc: 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 debug2: compression ctos: none debug2: compression stoc: none debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none debug3: send packet: type 30 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug3: receive packet: type 31 debug1: Server host key: ecdsa-sha2-nistp256 SHA256:CIwRhuKtgE68b/2Bl9dIfVkg2x//rBVPyupN7p54HwQ debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/known_hosts error:2 debug3: Failed to open file:C:\Users\Hamedsbt/.ssh/known_hosts2 error:2 debug3: Failed to open file:PROGRAMDATA\ssh/ssh_known_hosts error:2 debug3: Failed to open file:PROGRAMDATA\ssh/ssh_known_hosts2 error:2 debug3: failed to open file:/dev/tty error:3 debug1: read_passphrase: can't open /dev/tty: No such file or directory The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:CIwRhuKtgE68b/2Bl9dIfVkg2x//rBVPyupN7p54HwQ. Are you sure you want to continue connecting (yes/no)?

bagajjal commented 6 years ago

SSH client looks at the current user profile. In your case it's C:\Users\Hamedsbt/.ssh.

You can also copy them to %programdata%\ssh folder.

hamedsbt commented 6 years ago

I want to customize the "user profile" path and ssh filename for ssh client, how can I do that?