sftp 无法读取数据包:对端重置连接

sftp 无法读取数据包:对端重置连接

当我在本地计算机上执行以下命令时,我可以连接(要求输入密码):

sftp -v -oPort=2828 [email protected]

sftp -v 生成的日志:

OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to SERVER.COM [XX.XX.XX.XX] port 2828.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.6
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.6 pat OpenSSH* compat 0x04000000
debug1: Authenticating to SERVER.COM:2828 as 'USER'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
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: Server host key: ecdsa-sha2-nistp256 SHA256:xxxxxxxxxx
debug1: Host '[SERVER.COM]:2828' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:7
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: 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,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:iq/xxxxxxxxxxxxxxx /home//.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Password: 

当我在新配置的 ubuntu 服务器上尝试执行相同操作时,我从完全相同的命令收到以下错误:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to SERVER.COM [XX.XX.XX.XX] port 2828.
debug1: connect to address XX.XX.XX.XX port 2828: Connection timed out
ssh: connect to host SERVER.COM port 2828: Connection timed out
Couldn't read packet: Connection reset by peer

我按照网上的几条说明操作,但没有任何效果。

例子:SFTP 错误 - 无法读取数据包:对端重置连接

编辑:我无法访问我尝试通过 sftp 连接的服务器,它不是我的。

答案1

很难说,可能是路由不好?如果连接完全超时,则路由表不正确或服务器直接丢弃了您的数据包。检查您的网络配置,然后检查您的路由,然后您可以转到 SSH 日志、hosts.{allow,deny} 等。

答案2

在我的主机托管商的支持下解决了这个问题。

问题是,他们有安全组,除非你主动打开它们,否则会阻止所有端口。我没有打开端口 2828。

这对我来说仍然有点神秘,因为我认为 sftp -oPort=2828 会转到 TARGET 端口 2828,而我这边仍通过端口 22。但是好吧... 这解决了这个问题。感谢那些试图回答我的问题的人。

相关内容