反向 SSH“连接被 ::1 关闭”

反向 SSH“连接被 ::1 关闭”

我尝试建立远程 ssh 连接。

我尝试连接“远程”ssh -fN -R 10110:localhost:22 GatewayUser@GatewayHost

和“网关”ssh -p10110 RemoteUser@localhost

我在网关控制台上收到了响应Connection closed by ::1

使用 -v 运行它ssh -v -fN -R 10110:localhost:22 GatewayUser@GatewayHost

在远程控制台中生成该响应

debug1: client_input_global_request: rtype [email protected] want_reply 1
debug1: client_input_global_request: rtype [email protected] want_reply 1
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 2 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 10110, originator ::1 port 48481
debug1: connect_next: host localhost ([127.0.0.1]:22) in progress, fd=4
debug1: channel 0: new [::1]
debug1: confirm forwarded-tcpip
debug1: channel 0: connected to localhost port 22
debug1: channel 0: free: ::1, nchannels 1
debug1: client_input_global_request: rtype [email protected] want_reply 1
debug1: client_input_global_request: rtype [email protected] want_reply 1

PS:从远程到网关的 SSH 连接正在工作

提前谢谢了!

__

这里是从网关机器连接时的控制台输出emanuel@UbuntuServer:~$ ssh -vvv -p10110 pi@localhost

OpenSSH_6.7p1 Ubuntu-5ubuntu1.3, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [::1] port 10110.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/emanuel/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug3: put_host_port: [localhost]:10110
debug3: load_hostkeys: loading entries for host "[localhost]:10110" from file "/home/emanuel/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
Connection closed by ::1
emanuel@UbuntuServer:~$ 

答案1

您要做的是:创建一个从 raspi 到网关的 ssh 连接,并将 *:10110 从网关转发到 raspi 上的 127.0.0.1:22。然后连接到端口 10110@localhost,在某些配置中该端口可能使用 ip6 地址 (::1),其后面没有隧道。然后 sshd 关闭连接。尝试

ssh -4 -p10110 pi@localhost

这应该会让你更进一步。如果您在查找正确的密钥时遇到问题(ssh 在检查一定数量的密钥后停止),则禁用 pubkeyauth

ssh -oPubkeyAuthentication=no -4 -p10110 pi@localhost

答案2

您的ssh客户端似乎sshd通过 IPv6 连接到您的。是否sshd监听 IPv6 地址?添加此行/etc/ssh/sshd_config并重新启动sshd

ListenAddress ::

或者您可以使用ssh -4参数强制 IPv4 连接。

相关内容