You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SSH端口转发配置文件无法连接内部主机问题求助

SSH端口转发配置文件无法连接内部主机问题求助

大家好,我最近在把一条手动执行的SSH端口转发命令改成配置文件形式时遇到了麻烦,想请各位帮忙排查下问题所在。

我原本使用的SSH命令是可以正常建立端口转发的:

ssh -i identity-file.pem -L 20000:internal-host.com:8080 user@remote-host.com -N

为了后续使用更方便,我把它写成了SSH配置文件,内容如下:

Host remote-host-tunnel
  IdentitiesOnly yes
  HostName remote-host.com
  User user
  PubKeyAuthentication yes
  IdentityFile ~/.ssh/identity-file.pem
  ServerAliveInterval 30

Host internal-host-forwarding
  LocalForward 20000 internal-host.com:8080
  Hostname internal-host.com
  ProxyCommand ssh remote-host-tunnel nc %h %p

目前,我执行ssh remote-host-tunnel可以成功连接到远程主机,这部分是正常的。但当我尝试执行ssh internal-host-forwarding -N来建立到内部主机的转发时,连接始终无法建立,报错信息如下:

Ncat: Connection timed out.
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

有没有朋友能帮我看看配置哪里写错了?谢谢大家!

备注:内容来源于stack exchange,提问作者fingerprints

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 15:44:32