Что не так с gitlab и ключами s sh - PullRequest
       163

Что не так с gitlab и ключами s sh

1 голос
/ 05 августа 2020

имеет странные проблемы с ключами Gitlab и s sh. Я сделал

  1. Создал пару ключей rsa
  2. id_rsa_GitLab
  3. id_rsa_GitLab.pub
  4. добавил publi c ключ к моему gitlab account
  5. попытался проверить, может ли s sh подключиться к s sh -Tvvv git@xxxx.xx

при этом, я получил этот вывод

$ ssh -Tvvv git@xxxx.xx
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
debug1: Reading configuration data /c/Users/Ulrich Waibel/.ssh/config
debug1: /c/Users/Ulrich Waibel/.ssh/config line 2: Applying options for xxxx.xx
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "xxxx.xx" port 22
debug2: ssh_connect_direct
debug1: Connecting to xxxx.xx [xxx.xxx.xxx.153] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Ulrich Waibel/.ssh/id_rsa_GitLab type 0
debug1: identity file /c/Users/Ulrich Waibel/.ssh/id_rsa_GitLab-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version mod_sftp
debug1: no match: mod_sftp
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xxxx.xx:22 as 'git'
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-group14-sha256,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,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,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,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,aes256-cbc,aes192-cbc
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,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes192-ctr,aes256-ctr,aes128-ctr,aes192-cbc,aes256-cbc,aes128-cbc
debug2: ciphers stoc: aes192-ctr,aes256-ctr,aes128-ctr,aes192-cbc,aes256-cbc,aes128-cbc
debug2: MACs ctos: hmac-sha2-512,hmac-sha2-256,hmac-sha1
debug2: MACs stoc: hmac-sha2-512,hmac-sha2-256,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@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:jQZlCRVqhjK3w3CQWwpfbsUQaZxL5CGV1wYazbGUc7M
The authenticity of host 'xxxx.xx (xxx.xxx.xxx.153)' can't be established.
RSA key fingerprint is SHA256:jQZlCRVqhjK3w3CQWwpfbsUQaZxL5CGV1wYazbGUc7M.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'xxxx.xx,xxx.xxx.xxx.153' (RSA) to the list of known hosts.
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /c/Users/Ulrich Waibel/.ssh/id_rsa_GitLab RSA SHA256:1vaiihW8GNAzlMgDsoScFqMmxFw3FHScM1x30NboJZw explicit
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey
debug3: authmethod_lookup publickey
debug3: remaining preferred:
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/Ulrich Waibel/.ssh/id_rsa_GitLab RSA SHA256:1vaiihW8GNAzlMgDsoScFqMmxFw3FHScM1x30NboJZw explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
git@xxxx.xx: Permission denied (publickey,password).

Я использую Windows 10, git v2.28.0. windows .1 создал ключи с git - bash, а также s sh -T с git - bash все файлы находятся в $ ser $ .ssh, есть также файл конфигурации с этим содержимым

# GitLab.com
Host xxxx.xx
   Preferredauthentications publickey
   IdentityFile"/c/users/Ulrich Waibel/.ssh/id_rsa_GitLab"

Любая помощь приветствуется

1 Ответ

0 голосов
/ 06 августа 2020

Попробуйте со следующим файлом% USERPROFILE% .ssh \ config (убедитесь, что конец строки eol - LF, а не CRLF)

# GitLab.com
Host xxxx.xx
   Hostname <correct.hostname>
   Preferredauthentications publickey
   IdentityFile "/c/users/Ulrich Waibel/.ssh/id_rsa_GitLab"
   User git

или

# GitLab.com
Host xxxx.xx
   Hostname <correct.hostname>
   Preferredauthentications publickey
   IdentityFile C:\users\Ulrich Waibel\.ssh\id_rsa_GitLab
   User git

или

# GitLab.com
Host xxxx.xx
   Hostname <correct.hostname>
   Preferredauthentications publickey
   IdentityFile "C:\users\Ulrich Waibel\.ssh\id_rsa_GitLab"
   User git

Вы пропали Hostname gitlab.com. Поскольку вы можете добавить User git, тогда тест будет выглядеть следующим образом:

ssh -Tv xxxx.xx

OP Uli подтверждает в комментарий : запись Host содержит опечатку в его "<correct.hostname>"

...