L'authentification par clé Cygwin Openssh ne fonctionne pas dans l'environnement Windows

1

J'utilise Unison sur un ordinateur Windows 10 pour sauvegarder mes fichiers sur un serveur distant exécutant CentOS. Je me connecte à la machine distante sans mot de passe à l'aide d'OpenSSH et des clés publiques dans Cygwin. Je n'ai jamais eu de problèmes jusqu'à récemment.

Si je me connecte à la machine distante en utilisant ssh user@remoteaddressle shell Cygwin, je n’ai aucun problème et les touches fonctionnent. Si j'essaie exactement la même commande dans l'invite de commande Windows, la connexion demande mon mot de passe.

Tout cela a commencé après la modification de mon installation Cygwin. Cependant, j'ai essayé de réinstaller Cygwin et de générer de nouvelles clés, mais j'ai obtenu le même résultat.

Tous les threads que j'ai trouvés à ce sujet suggèrent de vérifier vos autorisations de fichier pour le répertoire .ssh sur le serveur et la machine locale. Toutefois, cela n’explique pas pourquoi cela fonctionne dans Cygwin mais pas dans Windows et que rien n’a changé sur le serveur.

J'ai ajouté Cygwin au chemin de l'environnement Windows correctement et je suis sshreconnu dans l'invite de commande. On a l'impression qu'OpenSSH ou Cygwin a été mis à jour et que la mise à jour a interrompu l'intégration avec Windows.

Je ne suis pas un programmeur, cela dépasse donc mes capacités pour le moment.

Voici les journaux de l'invite de commande et les journaux du shell Cygwin suivants:

Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\myname>ssh -vvv [email protected]
OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to myname.net [xx.xx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_rsa-cert type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: identity file /.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.4
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
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: [email protected],[email protected],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,[email protected]
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,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],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,[email protected]
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,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 123/256
debug2: bits set: 521/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: host myname.net filename /.ssh/known_hosts
debug3: check_host_in_hostfile: host myname.net filename /.ssh/known_hosts
debug3: check_host_in_hostfile: match line 2
debug3: check_host_in_hostfile: host xx.xx.xxx.xxx filename /.ssh/known_hosts
debug3: check_host_in_hostfile: host xx.xx.xxx.xxx filename /.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host 'myname.net' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:2
debug2: bits set: 486/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
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: /.ssh/id_rsa (0x0)
debug2: key: /.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
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: Trying private key: /.ssh/id_rsa
debug3: no such identity: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug3: no such identity: /.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:

... et du shell Cygwin:

myname@Windoze ~
$ ssh -vvv [email protected]
OpenSSH_7.1p1, OpenSSL 1.0.2e 3 Dec 2015
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to myname.net [xx.xx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/myname/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myname/.ssh/id_ed25519-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 myname.net:22 as 'myname'
debug3: hostkeys_foreach: reading file "/home/myname/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/myname/.ssh/know                                                                        n_hosts:1
debug3: load_hostkeys: loaded 1 keys from myname.net
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],ssh-                                                                        rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-                                                                        sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hel                                                                        lman-group-exchange-sha1,diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: [email protected],ssh-rsa,ecdsa-sha2-nistp                                                                        [email protected],[email protected],ecdsa-sha2-nis                                                                        [email protected],[email protected],ecdsa-sha2-nistp256,                                                                        ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,a                                                                        es256-ctr,[email protected],[email protected],arcfour256,arcfour128,ae                                                                        s128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndae                                                                        [email protected]
debug2: kex_parse_kexinit: [email protected],aes128-ctr,aes192-ctr,a                                                                        es256-ctr,[email protected],[email protected],arcfour256,arcfour128,ae                                                                        s128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndae                                                                        [email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],hmac                                                                        [email protected],[email protected],[email protected]                                                                        m,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1                                                                        ,[email protected],[email protected],hmac-sha1-96-etm@openss                                                                        h.com,[email protected],hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh                                                                        .com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],hmac                                                                        [email protected],[email protected],[email protected]                                                                        m,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1                                                                        ,[email protected],[email protected],hmac-sha1-96-etm@openss                                                                        h.com,[email protected],hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh                                                                        .com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],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-g                                                                        roup-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,arcfour12                                                                        8,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rij                                                                        [email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour12                                                                        8,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rij                                                                        [email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,                                                                        hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,                                                                        hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
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 [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1579/3072
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:1vQHO4ohl/PU9lJtFh8OVhQv0vdILmzJ4/AXdYt6                                                                        208
debug3: hostkeys_foreach: reading file "/home/myname/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/myname/.ssh/know                                                                        n_hosts:1
debug3: load_hostkeys: loaded 1 keys from myname.net
debug3: hostkeys_foreach: reading file "/home/myname/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/myname/.ssh/know                                                                        n_hosts:1
debug3: load_hostkeys: loaded 1 keys from xx.xx.xxx.xxx
debug1: Host 'myname.net' is known and matches the RSA host key.
debug1: Found key in /home/myname/.ssh/known_hosts:1
debug2: bits set: 1524/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: /home/myname/.ssh/id_rsa (0x60006bcf0),
debug2: key: /home/myname/.ssh/id_dsa (0x0),
debug2: key: /home/myname/.ssh/id_ecdsa (0x0),
debug2: key: /home/myname/.ssh/id_ed25519 (0x0),
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi                                                                        c,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-m                                                                        ic,password
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: /home/myname/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:bBS6l5Dl4OBi2MHpBjSxJmRHXg6Q5g3+PMKvHKNm                                                                        CZM
debug3: sign_and_send_pubkey: RSA SHA256:bBS6l5Dl4OBi2MHpBjSxJmRHXg6Q5g3+PMKvHKN                                                                        mCZM
debug1: Authentication succeeded (publickey).
Authenticated to myname.net ([xx.xx.xxx.xxx]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Sun Dec 20 08:34:02 2015 from ebradford.plus.com
[myname@mynameserver ~]$ debug2: client_check_window_change: changed
debug2: channel 0: request window-change confirm 0
[myname@mynameserver ~]$ ^C
Edwinbradford
la source
1) Examinez le journal détaillé de cygwinet à partir du shell Windows ( -vvvcommutateurs). 2) D'où provient la clé utilisée pour l'authentification, où est-elle stockée? 3) Si vous ne pouvez pas le comprendre vous-même, postez les journaux.
Jakuje
Merci @ Jakuje. Je ne savais pas comment voir les journaux. Je les ai téléchargés et modifié mes coordonnées pour des raisons de sécurité. Pouvez-vous voir quel est le problème?
Edwinbradford

Réponses:

0

SSH de MS Shell est même une version différente de celle de Cygwin:

OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010 (MS)
OpenSSH_7.1p1, OpenSSL 1.0.2e 3 Dec 2015 (cygwin)

Vous voyez la différence évidente entre Cygwin:

debug1: identity file /home/myname/.ssh/id_rsa type 1

et MS:

debug1: identity file /.ssh/id_rsa type -1

La version MS recherche une paire de clés dans un chemin sans signification et ne la trouve pas. Vous aurez probablement besoin d'essayer depuis le shell Windows comme ceci:

$ ssh -i /path/to/your/id_rsa [email protected]
Jakuje
la source
J'ai vu cela mais je n'étais pas sûr que ce soit le problème. Je vous remercie.
Edwinbradford
1
Unison ne semble pas avoir une méthode simple pour spécifier les paramètres SSH locaux, mais j'ai trouvé un meilleur correctif ici goo.gl/CAV2yI . Cygwin semble avoir changé la façon dont il définit le répertoire de base de Windows.
edwinbradford