为什么我的 ssh 隧道的远程连接被拒绝,但本地连接却被接受?

为什么我的 ssh 隧道的远程连接被拒绝,但本地连接却被接受?

您好,我已经设置了 ssh 隧道,如下所示: 

 /usr/bin/ssh -vvv -o ServerAliveInterval=10 -o ServerAliveCountMax=3 -R 15000:127.0.0.1: 15000 -N mylinode.domain.com
...
debug1: Offering public key: /Users/rcook/.ssh/id_rsa RSA SHA256:8Y33c0fxIoqd3SmemVpq5jOPdaqPQ/DnadmlP6A4q14
debug1: Server accepts key: /Users/rcook/.ssh/id_rsa RSA SHA256:8Y33c0fxIoqd3SmemVpq5jOPdaqPQ/DnadmlP6A4q14
Authenticated to mylinode.domain.com ([45.79.100.248]:22) using "publickey".
debug1: Remote connections from LOCALHOST:15000 forwarded to local address localhost:15000
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: client_input_hostkeys: searching /Users/rcook/.ssh/known_hosts for mylinode.domain.com / (none)
debug1: client_input_hostkeys: searching /Users/rcook/.ssh/known_hosts2 for mylinode.domain.com / (none)
debug1: client_input_hostkeys: hostkeys file /Users/rcook/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: pledge: network
debug1: Remote: /home/rcook/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/rcook/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts
debug1: remote forward success for: listen 15000, connect localhost:15000

在我的防火墙中,我已为该主机打开了 TCP 和 UDP 端口 22000。在 mylinode 上,我可以使用 本地连接到隧道,但是 telnet localhost 22000 ,我无法使用等效命令从另一台计算机进行连接。它立即给出错误:“连接被拒绝”。 

rcook@MacBook-Pro-2021 (obsidian-media-db-plugin (master)): nc -zv mylinode.domain.com 22000
nc: connectx to mylinode.domain.com port 22000 (tcp) failed: Connection refused

什么原因可能导致这种情况?以下是 /etc/sshd/sshd_config 中一些值得注意的设置:

#AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
X11Forwarding yes

答案1

好的,这个问题不知怎么就解决了。我甚至可以从外部主机连接到隧道。我没有做任何更改;也许连接端口在测试过程中以某种方式被锁定了?无论如何,一切都恢复正常了。很抱歉,我不知道是什么原因造成的。

相关内容