跳转主机会忽略自定义 ssh 配置

跳转主机会忽略自定义 ssh 配置

ssh在目录上有一个自定义配置。当-J传递跳转参数时,ssh忽略自定义配置,而是查看~/.ssh/config.

这是如何ProxyJump工作的还是一个错误?


工作:

ssh -vvv -F config -J [email protected] [email protected]

OpenSSH_9.3p1, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data config
debug1: config line 1: Applying options for *
debug2: resolve_canonicalize: hostname 10.0.3.120 is address
debug1: Setting implicit ProxyCommand from ProxyJump: ssh -l jump -F config -vvv -W '[%h]:%p' 192.168.56.11
debug1: Executing proxy command: exec ssh -l jump -F config -vvv -W '[10.0.3.120]:22' 192.168.56.11
debug1: identity file /home/strboul/.ssh/id_rsa type 0
debug1: identity file /home/strboul/.ssh/id_rsa-cert type -1
debug1: identity file /home/strboul/.ssh/id_ecdsa type -1
debug1: identity file /home/strboul/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/strboul/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/strboul/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/strboul/.ssh/id_ed25519 type -1
debug1: identity file /home/strboul/.ssh/id_ed25519-cert type -1
debug1: identity file /home/strboul/.ssh/id_ed25519_sk type -1
debug1: identity file /home/strboul/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/strboul/.ssh/id_xmss type -1
debug1: identity file /home/strboul/.ssh/id_xmss-cert type -1
debug1: identity file /home/strboul/.ssh/id_dsa type -1
debug1: identity file /home/strboul/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.3
OpenSSH_9.3p1, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data config
debug1: config line 1: Applying options for *
debug1: config line 9: Applying options for 192.168.56.11
debug2: resolve_canonicalize: hostname 192.168.56.11 is address
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.56.11 [192.168.56.11] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: identity file id_ed25519-client_test type 3
debug1: identity file id_ed25519-client_test-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.7
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.7 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.56.11:22 as 'jump'
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
debug3: order_hostkeyalgs: no algorithms matched; accept original
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: [email protected],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,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
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: 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
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,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]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:wUJgKzsnvmIfNKpldnCZEasb1RAvQV0B97Rr2zjRwvQ
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
Warning: Permanently added '192.168.56.11' (ED25519) to the list of known hosts.
debug3: send packet: type 21
debug2: ssh_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: ssh_set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug3: ssh_get_authentication_socket_path: path '/tmp/ssh-XXXXXXLePZAR/agent.15888'
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
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,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
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,keyboard-interactive
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
debug3: sign_and_send_pubkey: using publickey with ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI
debug3: sign_and_send_pubkey: signing using ssh-ed25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI
debug3: send packet: type 50
debug3: receive packet: type 52
Authenticated to 192.168.56.11 ([192.168.56.11]:22) using "publickey".
debug3: ssh_init_stdio_forwarding: 10.0.3.120:22
debug1: channel_connect_stdio_fwd: 10.0.3.120:22
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new stdio-forward [stdio-forward] (inactive timeout: 0)
debug3: fd 4 is O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: getpeername failed: Bad file descriptor
debug3: send packet: type 90
debug2: fd 3 setting TCP_NODELAY
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: client_repledge: enter
debug1: pledge: fork
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /etc/ssh/sshd_config.d/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 4
debug1: Remote: /etc/ssh/sshd_config.d/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.7
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.7 pat OpenSSH* compat 0x04000000
debug2: fd 5 setting O_NONBLOCK
debug2: fd 4 setting O_NONBLOCK
debug1: Authenticating to 10.0.3.120:22 as 'service2'
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
debug3: order_hostkeyalgs: no algorithms matched; accept original
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: [email protected],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,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
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: 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
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,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]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:AcrBUTeKSU89ylX1sz1NatDPp1i4HrLsIv5aXDCS0mE
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
Warning: Permanently added '10.0.3.120' (ED25519) to the list of known hosts.
debug3: send packet: type 21
debug2: ssh_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: ssh_set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug3: ssh_get_authentication_socket_path: path '/tmp/ssh-XXXXXXLePZAR/agent.15888'
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /home/strboul/.ssh/id_rsa RSA SHA256:HaEGWnCwC3qIn7zKYwZ79E1Ts3d0zMLKWM9lhyW1pl8
debug1: Will attempt key: /home/strboul/.ssh/id_ecdsa
debug1: Will attempt key: /home/strboul/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/strboul/.ssh/id_ed25519
debug1: Will attempt key: /home/strboul/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/strboul/.ssh/id_xmss
debug1: Will attempt key: /home/strboul/.ssh/id_dsa
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,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
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,keyboard-interactive
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/strboul/.ssh/id_rsa RSA SHA256:HaEGWnCwC3qIn7zKYwZ79E1Ts3d0zMLKWM9lhyW1pl8
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
debug1: Trying private key: /home/strboul/.ssh/id_ecdsa
debug3: no such identity: /home/strboul/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/strboul/.ssh/id_ecdsa_sk
debug3: no such identity: /home/strboul/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/strboul/.ssh/id_ed25519
debug3: no such identity: /home/strboul/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/strboul/.ssh/id_ed25519_sk
debug3: no such identity: /home/strboul/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/strboul/.ssh/id_xmss
debug3: no such identity: /home/strboul/.ssh/id_xmss: No such file or directory
debug1: Trying private key: /home/strboul/.ssh/id_dsa
debug3: no such identity: /home/strboul/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,password).
debug3: send packet: type 1
debug1: channel 0: free: direct-tcpip: listening port 0 for 10.0.3.120 port 22, connect from 127.0.0.1 port 65535 to UNKNOWN port 65536, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 direct-tcpip: listening port 0 for 10.0.3.120 port 22, connect from 127.0.0.1 port 65535 to UNKNOWN port 65536 (t4 [stdio-forward] r0 i0/0 o0/0 e[closed]/0 fd 4/5/-1 sock -1 cc -1 io 0x01/0x00)

Killed by signal 1.

这有效:

ssh -vvv -F config -tt [email protected] ssh [email protected]

OpenSSH_9.3p1, OpenSSL 3.0.8 7 Feb 2023
debug1: Reading configuration data config
debug1: config line 1: Applying options for *
debug1: config line 9: Applying options for 192.168.56.11
debug2: resolve_canonicalize: hostname 192.168.56.11 is address
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.56.11 [192.168.56.11] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: identity file id_ed25519-client_test type 3
debug1: identity file id_ed25519-client_test-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.7
debug1: compat_banner: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.7 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.56.11:22 as 'jump'
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
debug3: order_hostkeyalgs: no algorithms matched; accept original
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: [email protected],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,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
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: 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
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,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]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:wUJgKzsnvmIfNKpldnCZEasb1RAvQV0B97Rr2zjRwvQ
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
Warning: Permanently added '192.168.56.11' (ED25519) to the list of known hosts.
debug3: send packet: type 21
debug2: ssh_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: ssh_set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug3: ssh_get_authentication_socket_path: path '/tmp/ssh-XXXXXXLePZAR/agent.15888'
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
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,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
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,keyboard-interactive
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: id_ed25519-client_test ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI explicit
debug3: sign_and_send_pubkey: using publickey with ED25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI
debug3: sign_and_send_pubkey: signing using ssh-ed25519 SHA256:1zzOdFQiBRu5EFHKIq1V0TfvYhHLGWNbaTyDn1m7giI
debug3: send packet: type 50
debug3: receive packet: type 52
Authenticated to 192.168.56.11 ([192.168.56.11]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: client_repledge: enter
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /etc/ssh/sshd_config.d/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 4
debug1: Remote: /etc/ssh/sshd_config.d/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending command: ssh [email protected]
debug2: channel 0: request exec confirm 1
debug3: send packet: type 98
debug3: client_repledge: enter
debug1: pledge: fork
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-149-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Last login: Tue May 30 11:09:04 2023 from 10.0.3.100
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

service2@service2:~$

目录内容:

config
id_ed25519-client_test
id_ed25519-client_test.pub

配置文件:

Host *
    PasswordAuthentication no
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Host 192.168.56.11
    IdentityFile id_ed25519-client_test

答案1

这两种方法并不等同,我认为你的解释是错误的。

您从本地计算机连接到,然后再连接到(通过在 上运行)。第二个连接使用用户可用的凭据和配置(您的本地配置与此连接无关)。两个连接都成功。ssh … [email protected] ssh [email protected]192.168.56.11192.168.56.1110.0.3.120ssh [email protected]192.168.56.11jump192.168.56.11

从本地计算机连接到然后ssh … -J [email protected] [email protected]192.168.56.11从您的本地计算机10.0.3.120,使用通过 转发的数据包192.168.56.11。第二个连接使用本地用户可用的凭据和配置。跳转主机上的配置和密钥无关,ssh跳转主机上没有运行任何进程。每个连接都在您的本地计算机中启动并涉及您的本地配置。这是第二次连接失败。

192.168.56.11在每种情况下,从本地计算机的连接都有效。我没有看到任何证据表明您的自定义配置被忽略。区别在于后来发生的事情。

看起来:

这就是区别。

您发布的配置文件(它是本地配置,对吧?)包含 的条目192.168.56.11,但没有 的条目10.0.3.120。如果您想在从本地连接时使用相同的身份文件,10.0.3.120那么您需要添加

Host 10.0.3.120
    IdentityFile id_ed25519-client_test

到本地配置。


旁注(参见man 5 ssh_config):对于每个参数,将使用第一个获得的值。因此,您通常应该将特定于主机的声明放置在文件开头附近,并将一般默认值放置在文件末尾。你Host *以前有过Host 192.168.56.11。目前的配置没有问题然而,但是通过进一步自定义配置,您可能会遇到以下情况:下面的某些行Host *与下面的某些行发生冲突Host 192.168.56.11,那么下面的行将Host *“获胜”(例子)。考虑将该Host *部分移至末尾。

相关内容