我试图使用ssh从Microsoft连接到GitLab,但是响应这个命令ssh -Tvvv git@gitlab.markitasdone.com
,我得到了以下错误:
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug3: Failed to open file:C:/Users/Saeed/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "gitlab.markitasdone.com" port 22
debug2: ssh_connect_direct
debug1: Connecting to gitlab.markitasdone.com [142.93.9.7] port 22.
debug1: Connection established.
debug3: Failed to open file:C:/Users/Saeed/.ssh/id_rsa error:2
debug3: Failed to open file:C:/Users/Saeed/.ssh/id_rsa.pub error:2
debug1: identity file C:\\Users\\Saeed/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to gitlab.markitasdone.com:22 as 'git'
debug3: hostkeys_foreach: reading file "C:\\Users\\Saeed/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\Saeed/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from gitlab.markitasdone.com
debug3: Failed to open file:C:/Users/Saeed/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: order_hostkeyalgs: prefer hostkeyalgs: 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
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: reserved 0
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug3: hostkeys_foreach: reading file "C:\\Users\\Saeed/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\Saeed/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from gitlab.markitasdone.com
debug3: Failed to open file:C:/Users/Saeed/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: hostkeys_foreach: reading file "C:\\Users\\Saeed/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\Saeed/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 142.93.9.7
debug3: Failed to open file:C:/Users/Saeed/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug1: Host 'gitlab.markitasdone.com' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\Saeed/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 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 134217728 blocks
debug3: unable to connect to pipe \\\\.\\pipe\\openssh-ssh-agent, error: 2
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\Saeed/.ssh/id_rsa
debug1: Will attempt key: C:\\Users\\Saeed/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\Saeed/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\Saeed/.ssh/id_ed25519 ED25519 SHA256:oG6rH82EthXFIeexWntA7mmsYb+h/d5lMGXc+2REW0k
debug1: Will attempt key: C:\\Users\\Saeed/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
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
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: Trying private key: C:\\Users\\Saeed/.ssh/id_rsa
debug3: no such identity: C:\\Users\\Saeed/.ssh/id_rsa: No such file or directory
debug1: Trying private key: C:\\Users\\Saeed/.ssh/id_dsa
debug3: no such identity: C:\\Users\\Saeed/.ssh/id_dsa: No such file or directory
debug1: Trying private key: C:\\Users\\Saeed/.ssh/id_ecdsa
debug3: no such identity: C:\\Users\\Saeed/.ssh/id_ecdsa: No such file or directory
debug1: Offering public key: C:\\Users\\Saeed/.ssh/id_ed25519 ED25519 SHA256:oG6rH82EthXFIeexWntA7mmsYb+h/d5lMGXc+2REW0k
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
debug1: Trying private key: C:\\Users\\Saeed/.ssh/id_xmss
debug3: no such identity: C:\\Users\\Saeed/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
git@gitlab.markitasdone.com: Permission denied (publickey).
值得注意的是,就在一个月前,我还能够连接到GitLab,没有任何问题。今天,当我收到上述错误时,我决定删除ssh键,并在GitLab指令之后生成另一个键。
从错误来看,它似乎在寻找ssh文件夹中的一个配置文件。我查过文件夹,但那里没有这样的文件。是否必须为ssh创建一个配置文件才能再次工作?如果是的话,这个文件应该包含哪些内容?
Update:ls -l
命令在.ssh
目录中的输出是:
total 12
-rw------- 1 saeed saeed 399 Jan 16 18:30 id_ed25519
-rw-r--r-- 1 saeed saeed 91 Jan 16 18:30 id_ed25519.pub
-rw-r--r-- 1 saeed saeed 888 Jan 16 10:20 known_hosts
id
的输出是:
uid=1000(saeed) gid=1000(saeed) groups=1000(saeed),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev)
发布于 2022-01-16 09:03:09
欢迎来到StackOverflow。
这是日志消息中有趣的部分:
debug3: Failed to open file:C:/Users/Saeed/.ssh/id_rsa error:2
debug3: Failed to open file:C:/Users/Saeed/.ssh/id_rsa.pub error:2
由于某些原因(这取决于您理解原因),无法访问该路径。尝试打开您的文件管理器,然后转到那个位置。
可能您没有从该计算机或该用户帐户生成密钥,以便:
/Users/Saeed/.ssh
是否存在C:/Users/Saeed/.ssh/id_rsa
是否存在如果不是,请查看如何生成新的SSH密钥。
https://stackoverflow.com/questions/70728566
复制相似问题