我正在尝试使用以下命令从 Windows 10 计算机的 CMD 中启动的 SSH 会话连接到 Docker Playground 实例:
ssh -v ip172-18-0-18-cbepm33cukq00090gvu0@direct.labs.play-with-docker.com
这是 SSH 输出:
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to direct.labs.play-with-docker.com [40.76.55.146] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\Marciano/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\Marciano/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_ed25519 type 3
debug1: identity file C:\\Users\\Marciano/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\Marciano/.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 Go
debug1: no match: Go
debug1: Authenticating to direct.labs.play-with-docker.com:22 as 'ip172-18-0-18-cbepm33cukq00090gvu0'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:UyqFRi42lglohSOPKn6Hh9M83Y5Ic9IQn1PTHYqOjEA
debug1: Host 'direct.labs.play-with-docker.com' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\Marciano/.ssh/known_hosts:19
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_rsa RSA SHA256:BZFw2ybMWiH6PSOug+zBT90LhgwoxDMR0Ci7wAeJs/I
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug1: Server accepts key: C:\\Users\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug1: Authentication succeeded (publickey).
Authenticated to direct.labs.play-with-docker.com ([40.76.55.146]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: ENABLE_VIRTUAL_TERMINAL_INPUT is supported. Reading the VTSequence from console
debug1: ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported. Console supports the ansi parsing
Connecting to 52.188.151.184:8022
debug1: channel 0: free: client-session, nchannels 1
Connection to direct.labs.play-with-docker.com closed.
Transferred: sent 2212, received 1436 bytes, in 1.1 seconds
Bytes per second: sent 1985.7, received 1289.1
debug1: Exit status -1
日志显示,身份验证成功后,连接立即关闭,进程以 -1 状态退出。
我还尝试连接 PUTTY 客户端和我使用 puttygen.exe 创建的自定义 .pkk 文件,如 通过 putty 连接到 play-with-docker 实例中的建议,但是 SSH 连接失败,并显示 服务器拒绝分配 pty 状态。
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2022.07.24 17:13:47 =~=~=~=~=~=~=~=~=~=~=~=
Using username "ip172-18-0-18-cbepm33cukq00090gvu0".
Authenticating with public key "rsa-key-20220724"
Connecting to 52.188.151.184:8022
Server refused to allocate pty
下面是使用 -vvv 生成的更详细的输出
ssh -vvv ip172-18-0-18-cbepm33cukq00090gvu0@direct.labs.play-with-docker.com
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug3: Failed to open file:C:/Users/Marciano/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "direct.labs.play-with-docker.com" port 22
debug2: ssh_connect_direct
debug1: Connecting to direct.labs.play-with-docker.com [40.76.55.146] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\Marciano/.ssh/id_rsa type 0
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_rsa-cert.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_dsa.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_dsa-cert.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ecdsa.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ecdsa-cert.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\Marciano/.ssh/id_ed25519 type 3
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_ed25519-cert.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_xmss.pub error:2
debug1: identity file C:\\Users\\Marciano/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/Marciano/.ssh/id_xmss-cert.pub error:2
debug1: identity file C:\\Users\\Marciano/.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 Go
debug1: no match: Go
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to direct.labs.play-with-docker.com:22 as 'ip172-18-0-18-cbepm33cukq00090gvu0'
debug3: hostkeys_foreach: reading file "C:\\Users\\Marciano/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file C:\\Users\\Marciano/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from direct.labs.play-with-docker.com
debug3: Failed to open file:C:/Users/Marciano/.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: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
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,[email protected],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,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],arcfour256,arcfour128
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],arcfour256,arcfour128
debug2: MACs ctos: [email protected],hmac-sha2-256,hmac-sha1,hmac-sha1-96
debug2: MACs stoc: [email protected],hmac-sha2-256,hmac-sha1,hmac-sha1-96
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: [email protected]
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] 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:UyqFRi42lglohSOPKn6Hh9M83Y5Ic9IQn1PTHYqOjEA
debug3: hostkeys_foreach: reading file "C:\\Users\\Marciano/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file C:\\Users\\Marciano/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from direct.labs.play-with-docker.com
debug3: Failed to open file:C:/Users/Marciano/.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\\Marciano/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file C:\\Users\\Marciano/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from 40.76.55.146
debug3: Failed to open file:C:/Users/Marciano/.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 'direct.labs.play-with-docker.com' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\Marciano/.ssh/known_hosts:19
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\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_rsa RSA SHA256:BZFw2ybMWiH6PSOug+zBT90LhgwoxDMR0Ci7wAeJs/I
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\Marciano/.ssh/id_xmss
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
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: Offering public key: C:\\Users\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: C:\\Users\\Marciano/.ssh/id_ed25519 ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0 agent
debug3: sign_and_send_pubkey: ED25519 SHA256:/p+cVcQBROp4X3eq1wi10tfgBSVUmKDaV2/hpxNTzM0
debug3: sign_and_send_pubkey: signing using ssh-ed25519
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to direct.labs.play-with-docker.com ([40.76.55.146]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug1: ENABLE_VIRTUAL_TERMINAL_INPUT is supported. Reading the VTSequence from console
debug3: This windows OS supports conpty
debug1: ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported. Console supports the ansi parsing
debug3: Successfully set console output code page from:65001 to 65001
debug3: Successfully set console input code page from:850 to 65001
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug2: channel 0: rcvd ext data 35
Connecting to 52.188.151.184:8022
debug2: channel 0: written 35 to efd 6
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: channel 0: output open -> drain
debug2: channel 0: chan_shutdown_read (i0 o1 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: obuf empty
debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug3: Successfully set console output code page from 65001 to 65001
debug3: Successfully set console input code page from 65001 to 850
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1)
debug3: send packet: type 1
debug3: Successfully set console output code page from 65001 to 65001
debug3: Successfully set console input code page from 65001 to 850
Connection to direct.labs.play-with-docker.com closed.
Transferred: sent 2212, received 1436 bytes, in 1.1 seconds
Bytes per second: sent 1964.8, received 1275.5
debug1: Exit status -1
预先感谢您的帮助。
就我而言,我无法连接。
debug1: Offering public key: /c/Users/thiru/.ssh/id_rsa RSA SHA256:okCget2rl5sGoR024BKQkKZrv/7lwc/CZ98bDmECvF8
debug1: send_pubkey_test: no mutual signature algorithm
ed25519
而不是 rsa。要从 Git bash 终端修复此问题,我必须使用 ed25519 创建一个新的 ssh 密钥
$ ssh-keygen -t ed25519 -P "" -f ~/.ssh/id_ed25519
Generating public/private ed25519 key pair.
Your identification has been saved in /c/Users/thiru/.ssh/id_ed25519
Your public key has been saved in /c/Users/thiru/.ssh/id_ed25519.pub
ssh -v ip17212-***********@direct.labs.play-with-docker.com
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to direct.labs.play-with-docker.com [40.*.*.146] port 22.
debug1: Connection established.
...
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version Go
debug1: compat_banner: no match: Go
debug1: Authenticating to direct.labs.play-with-docker.com:22 as 'ip172-****-*********'
debug1: load_hostkeys: fopen /c/Users/thiru/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:vCb*******************
debug1: load_hostkeys: fopen /c/Users/thiru/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'direct.labs.play-with-docker.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/thiru/.ssh/known_hosts:8
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/thiru/.ssh/id_rsa RSA SHA256:okCget2rl5sGoR024BKQkKZrv/7lwc/CZ98bDmECvF8
debug1: Will attempt key: /c/Users/thiru/.ssh/id_dsa
debug1: Will attempt key: /c/Users/thiru/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/thiru/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/thiru/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/thiru/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/thiru/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/thiru/.ssh/id_rsa RSA SHA256:okCget2rl5sGoR024BKQkKZrv/7lwc/CZ98bDmECvF8
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: /c/Users/thiru/.ssh/id_dsa
debug1: Trying private key: /c/Users/thiru/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/thiru/.ssh/id_ecdsa_sk
debug1: Trying private key: /c/Users/thiru/.ssh/id_ed25519
debug1: Trying private key: /c/Users/thiru/.ssh/id_ed25519_sk
debug1: Trying private key: /c/Users/thiru/.ssh/id_xmss
debug1: No more authentication methods to try.
ip172-1*****2-cd5d********[email protected]: Permission denied (publickey).
1.首先在 docker Playground 的终端上运行以下命令:
cat ~/.ssh/id_rsa.pub
结果将类似于:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB029t4sF6xjc8O9xV2 root@builsandbox
2.在本地 Linux 打开终端/在 Windows 上从您想要 ssh 的位置打开 git bash。
3.运行以下命令:
ssh-keygen -t ed25519 -P "" -f ~/.ssh/id_ed25519
在第一个命令的结果中,如果 ed25519 不同,则将 ed25519 替换为该名称。
4.使用 docker Playground 网页上找到的 ssh ip 运行以下命令:
ssh -v ip172-18-0-98-***@direct.labs.play-with-docker.com