gitlab和ssh密钥有什么问题

gitlab和ssh密钥有什么问题,ssh,gitlab,git-bash,Ssh,Gitlab,Git Bash,Gitlab和ssh密钥有一些奇怪的问题。 我所做的是 创建了一对rsa密钥 id\u rsa\u GitLab id\u rsa\u GitLab.pub 已将公钥添加到我的gitlab帐户 尝试验证ssh是否能够与ssh-Tvvv连接git@xxxx.xx 这样做时,我得到了这个输出 $ ssh -Tvvv git@xxxx.xx OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020 debug1: Reading configuration data /c/

Gitlab和ssh密钥有一些奇怪的问题。 我所做的是

  • 创建了一对rsa密钥
  • id\u rsa\u GitLab
  • id\u rsa\u GitLab.pub
  • 已将公钥添加到我的gitlab帐户
  • 尝试验证ssh是否能够与ssh-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).
    
    我使用的是Windows10,GitV2.28.0.Windows.1 使用GitBash创建密钥,并使用GitBash执行ssh-T 所有文件都位于$ser$.ssh中 还有一个包含此内容的配置文件

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

    非常感谢您提供的任何帮助

    请尝试使用以下%USERPROFILE%.ssh\config文件(确保下线末端为LF,而不是CRLF)


    确认:主机条目的“

    中有一个输入错误,请尝试使用以下%USERPROFILE%.ssh\config文件(确保下线末尾是LF,而不是CRLF)


    确认:主机条目的“

    中有输入错误,谢谢您的回复。我将主机名更改为gitlab实例(我们在自己的主机上运行prem上的gitlab),并按照您的建议设置用户。在我的配置文件中,我有一个到我的私人github帐户的第二个连接,它工作正常。另外,连接到我的私人GitLab帐户也可以正常工作。只有针对我们自己的主机的身份验证不起作用。我创建了一个新的ssh密钥并替换了现有的ssh密钥,但这并没有帮助。遇到问题了。添加hostname属性后,我在hostname值中输入了一个错误。修好后效果很好谢谢你的回复。我将主机名更改为gitlab实例(我们在自己的主机上运行prem上的gitlab),并按照您的建议设置用户。在我的配置文件中,我有一个到我的私人github帐户的第二个连接,它工作正常。另外,连接到我的私人GitLab帐户也可以正常工作。只有针对我们自己的主机的身份验证不起作用。我创建了一个新的ssh密钥并替换了现有的ssh密钥,但这并没有帮助。遇到问题了。添加hostname属性后,我在hostname值中输入了一个错误。修复后,它的工作良好
    # 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
    
    ssh -Tv xxxx.xx