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

SSH配置:通过跳板机获取动态主机名连接目标节点的问题求助

SSH配置:通过跳板机获取动态主机名连接目标节点的问题求助

大家好,我最近配置SSH时碰到了个棘手的问题,想请各位大佬帮忙分析下。我的需求是这样的:

  • 先连接到一台跳板机(登录节点)
  • 在跳板机上执行命令,动态获取目标主机的主机名
  • 最后用登录跳板机的相同用户名和凭据,连接到这个动态获取的主机

我自己写了一份.ssh/config配置,内容如下:

Host jump-server
    HostName loginnode
    User user

Host remote
    User user
    IdentityFile C:\Users\user\.ssh\id_rsa
    ForwardX11 yes
    ForwardX11Trusted yes
    XAuthLocation /usr/bin/xauth
    ProxyCommand ssh -q jump-server "ssh user@`command_to_get_the_hostname` bash -l"

之后我用这条命令尝试连接:

ssh.exe -v remote

但得到了异常的调试输出,明显有错误:

OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\user/.ssh/config
debug1: C:\\Users\\user/.ssh/config line 14: Applying options for remote
debug1: Executing proxy command: exec ssh -q jump-server "ssh lemoni15@`command_to_get_the_hostname` bash -l"
debug1: identity file C:\\Users\\user\\.ssh\\id_rsa type 0
debug1: identity file C:\\Users\\user\\.ssh\\id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
: command not foundSH_for_Windows_8.1

有没有大佬能帮我定位下问题所在,告诉我该怎么调整配置才能实现预期的功能呢?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 13:32:58