假设我的服务器拥有“我的”ip。客户端是一台具有ip 192.168.15.120的linux (debian)机器。我尝试从另一台计算机(Windows)在同一子网与ip 192.168.15.106。‘'my’是一个在互联网上使用ip 195.xxx.xxx.xxx (当然是在局域网之外)的服务器。Windows机器可能是ssh到我的,而我( linux客户端)不能。当我在服务器上将ssh端口更改为7822时,我的客户机可以将ssh更改为它。好像我的客户上有22端口的东西是错的。你的意见呢?我怎样才能追踪问题并找到它呢?
在运行ssh -v my之后,我得到了以下输出:
debug1: Reading configuration data /home/hamidi/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to my [195.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/hamidi/.ssh/id_rsa type 0
debug1: identity file /home/hamidi/.ssh/id_rsa-cert type -1
debug1: identity file /home/hamidi/.ssh/id_dsa type -1
debug1: identity file /home/hamidi/.ssh/id_dsa-cert type -1
debug1: identity file /home/hamidi/.ssh/id_ecdsa type -1
debug1: identity file /home/hamidi/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/hamidi/.ssh/id_ed25519 type -1
debug1: identity file /home/hamidi/.ssh/id_ed25519-cert type -1
debug1: identity file /home/hamidi/.ssh/id_xmss type -1
debug1: identity file /home/hamidi/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to my:22 as 'hamidi'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:GLEbQGgsPG4q1m5NpQpx1qgfGH+niS93ZQqz/m+amIM
The authenticity of host 'my (195.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is SHA256:GLEbQGgsPG4q1m5NpQpx1qgfGH+niS93ZQqz/m+amIM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'my,195.xxx.xxx.xxx' (RSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /home/hamidi/.ssh/id_rsa RSA SHA256:XPZJP0PUv/cEg+Z0tsDL6sm8aTEkl/vt+ewJt/RwwH8 agent
debug1: Will attempt key: /home/hamidi/.ssh/id_dsa
debug1: Will attempt key: /home/hamidi/.ssh/id_ecdsa
debug1: Will attempt key: /home/hamidi/.ssh/id_ed25519
debug1: Will attempt key: /home/hamidi/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/hamidi/.ssh/id_rsa RSA SHA256:XPZJP0PUv/cEg+Z0tsDL6sm8aTEkl/vt+ewJt/RwwH8 agent
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/hamidi/.ssh/id_dsa
debug1: Trying private key: /home/hamidi/.ssh/id_ecdsa
debug1: Trying private key: /home/hamidi/.ssh/id_ed25519
debug1: Trying private key: /home/hamidi/.ssh/id_xmss
debug1: Next authentication method: password
hamidi@my's password:
debug1: Authentication succeeded (password).
Authenticated to my ([195.xxx.xxx.xxx]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-184-generic x86_64)
...发布于 2020-06-29 14:23:59
在linux中调试ssh问题的最大工具可能是ssh -v <ip>和ssh -vv <ip>。您还可以将其与切换端口结合起来,因为您提到了默认端口示例:ssh -v -p 7822 <ip>存在问题。
编辑:正如注释中提到的,您可能希望查看服务器上的sshd日志,这些日志通常位于/var/log/auth.log中,用于ubuntu/debian,可能因为无法连接到tail -f /var/log/auth.log而跟踪日志。
https://serverfault.com/questions/1023344
复制相似问题