在我的办公网络中,我的一个客户端 (CentOS 7.5) 无法连接到远程服务器。远程服务器运行的是 CentOS 5.11,并且安装了 iptables 和 csf。
但是,即使我在远程主机上禁用了 iptables 和 csf,我的客户端也无法连接它:
# ssh -vvv x.x.x.x -p 2200
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug2: resolving "x.x.x.x" port 2200
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to x.x.x.x [x.x.x.x] port 2200.
debug1: connect to address x.x.x.xport 2200: Connection refused
ssh: connect to host x.x.x.x port 2200: Connection refused
~/.ssh/config
在客户端上:
AddressFamily inet
/etc/ssh/ssh_config
在客户端上:
ForwardX11Trusted yes
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
SendEnv XMODIFIERS
AddressFamily inet
服务器端的 sshd debug 为空,并且日志上没有防火墙/身份验证阻止消息。
在同一网络中的 Ubuntu 20.04 PC 上,我可以毫无问题地连接到该服务器。(运行 OpenSSH_8.2p1 Ubuntu-4ubuntu0.1、OpenSSL 1.1.1f 2020 年 3 月 31 日)。
更新
远程服务器上已禁用 SELinux。
Ubuntu 20.04 PC上的ssh日志:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/neil/.ssh/config
debug1: /home/neil/.ssh/config line 6: Applying options for *
debug3: kex names ok: [diffie-hellman-group-exchange-sha1]
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname x.x.x.x is address
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/neil/.ssh/controlmasters/[email protected]" does not exist
debug2: ssh_connect_direct
debug1: Connecting to x.x.x.x [x.x.x.x] port 2200.
debug1: Connection established.
debug1: identity file /home/neil/.ssh/id_rsa type 0
debug1: identity file /home/neil/.ssh/id_rsa-cert type -1
debug1: identity file /home/neil/.ssh/id_dsa type -1
debug1: identity file /home/neil/.ssh/id_dsa-cert type -1
debug1: identity file /home/neil/.ssh/id_ecdsa type -1
debug1: identity file /home/neil/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/neil/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/neil/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/neil/.ssh/id_ed25519 type -1
debug1: identity file /home/neil/.ssh/id_ed25519-cert type -1
debug1: identity file /home/neil/.ssh/id_ed25519_sk type -1
debug1: identity file /home/neil/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/neil/.ssh/id_xmss type -1
debug1: identity file /home/neil/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_2*,OpenSSH_3*,OpenSSH_4* compat 0x00000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to x.x.x.x:2200 as 'root'
debug3: put_host_port: [x.x.x.x]:2200
debug3: hostkeys_foreach: reading file "/home/neil/.ssh/known_hosts"
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-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
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: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
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: diffie-hellman-group1-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug2: bits set: 498/1024
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:aWGCYluAvO4zVxzSg8aebVzxWFhqS8gXqB9HwHO18ss
debug3: put_host_port: [x.x.x.x]:2200
debug3: put_host_port: [x.x.x.x]:2200
debug3: hostkeys_foreach: reading file "/home/neil/.ssh/known_hosts"
debug3: hostkeys_foreach: reading file "/home/neil/.ssh/known_hosts"
debug1: checking without port identifier
debug3: hostkeys_foreach: reading file "/home/neil/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/neil/.ssh/known_hosts:51
debug3: load_hostkeys: loaded 1 keys from x.x.x.x
debug1: Host 'x.x.x.x' is known and matches the RSA host key.
debug1: Found key in /home/neil/.ssh/known_hosts:51
debug1: found matching key w/out port
debug2: bits set: 495/1024
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: /home/neil/.ssh/id_rsa RSA SHA256:aNIfT0BtU3emp9xhmG6yVDWcQl8WqBq4FBUeAeuZNdw agent
debug1: Will attempt key: /home/neil/.ssh/id_dsa
debug1: Will attempt key: /home/neil/.ssh/id_ecdsa
debug1: Will attempt key: /home/neil/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/neil/.ssh/id_ed25519
debug1: Will attempt key: /home/neil/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/neil/.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,gssapi-with-mic
debug3: start over, passed a different list publickey,gssapi-with-mic
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/neil/.ssh/id_rsa RSA SHA256:aNIfT0BtU3emp9xhmG6yVDWcQl8WqBq4FBUeAeuZNdw agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /home/neil/.ssh/id_rsa RSA SHA256:aNIfT0BtU3emp9xhmG6yVDWcQl8WqBq4FBUeAeuZNdw agent
debug3: sign_and_send_pubkey: RSA SHA256:aNIfT0BtU3emp9xhmG6yVDWcQl8WqBq4FBUeAeuZNdw
debug3: sign_and_send_pubkey: signing using ssh-rsa SHA256:aNIfT0BtU3emp9xhmG6yVDWcQl8WqBq4FBUeAeuZNdw
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to x.x.x.x ([x.x.x.x]:2200).
debug1: setting up multiplex master socket
debug3: muxserver_listen: temporary control path /home/neil/.ssh/controlmasters/[email protected]
debug2: fd 4 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: channel 0: new [/home/neil/.ssh/controlmasters/[email protected]]
debug3: muxserver_listen: mux listener channel 0 fd 4
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug1: control_persist_detach: backgrounding master process
debug2: control_persist_detach: background process is 177393
debug2: fd 4 setting O_NONBLOCK
debug1: forking to background
debug1: Entering interactive session.
debug1: pledge: id
debug2: set_control_persist_exit_time: schedule exit in 300 seconds
debug1: multiplexing control connection
debug2: fd 5 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 1: new [mux-control]
debug3: channel_post_mux_listener: new mux channel 1 fd 5
debug3: mux_master_read_cb: channel 1: hello sent
debug2: set_control_persist_exit_time: cancel scheduled exit
debug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4
debug2: mux_master_process_hello: channel 1 slave version 4
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4
debug2: mux_master_process_alive_check: channel 1: alive check
debug3: mux_client_request_alive: done pid = 177395
debug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 70
debug3: mux_client_request_session: session request sent
debug2: mux_master_process_new_session: channel 1: request tty 1, X 0, agent 0, subsys 0, term "xterm-256color", cmd "", env 1
debug3: mux_master_process_new_session: got fds stdin 6, stdout 7, stderr 8
debug1: channel 2: new [client-session]
debug2: mux_master_process_new_session: channel_new: 2 linked to control channel 1
debug2: channel 2: send open
debug3: send packet: type 90
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 2: callback start
debug2: client_session2_setup: id 2
debug2: channel 2: request pty-req confirm 1
debug3: send packet: type 98
debug1: Sending environment.
debug1: Sending env LANG = en_NZ.UTF-8
debug2: channel 2: request env confirm 0
debug3: send packet: type 98
debug2: channel 2: request shell confirm 1
debug3: send packet: type 98
debug3: mux_session_confirm: sending success reply
debug2: channel_input_open_confirmation: channel 2: callback done
debug2: channel 2: open confirm rwindow 0 rmax 32768
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 2
debug2: PTY allocation request accepted on channel 2
debug2: channel 2: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 2
debug2: shell request accepted on channel 2
Last login: Tue Aug 11 09:33:30 2020 from XXXX
[root@remote_server ~] #