SSH 通过多个主机执行另一个 ssh 会话 [英] SSH through multiple hosts to execute another ssh session

查看:74
本文介绍了SSH 通过多个主机执行另一个 ssh 会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很多时间尝试做一些用简单的话来说看起来很简单的事情

I spent to much time trying to do something which in plain words looks simple

我在家,没有防火墙和所有开放端口.我需要通过 ssh 连接到工作中的路由器,在那里我可以访问 ssh 端口 22.我的个人机器位于具有内部 IP 地址的子网上.所以,我需要做的是从一台机器到第二台,从第二台到第三台.第三次我需要执行另一个 ssh,它将一些端口通过隧道连接到我的家用机器.所有这些都在我家的 bash 脚本中.我在互联网上尝试了很多解决方案,但没有任何效果.

I am at home, without firewall and all open ports. I need to ssh to the router at work where I have access to ssh port 22. My personal machine is on that subnet having internal ip address. So, what I need to do is to ssh from one machine to the second and from the second to the third. On the third I need to execute another ssh which tunnels some ports to my home machine. All that in bash script from my home. I have tried many solutions on the internet but nothing works.

整个理想是在我的工作电脑上运行并运行端口 22 的 ssh 隧道,这将允许我对我的工作电脑进行 sshfs.

The whole ideal is to get to my PC at work and run ssh tunnel for port 22 which will allow me to sshfs my work PC.

我可以手动完成,通过 ssh 到路由器,从路由器到工作电脑,然后执行 ssh 隧道.我需要一键式解决方案.

I could do it manually, by sshing to the router, that form the router to the work pc and then execute the ssh tunnel. I need a one-click solution.

提前致谢!

推荐答案

你有没有试过像 ssh -t localhost ssh localhost 这样的 ssh 命令堆叠起来,一定要添加 -t 选项,除了最后一个 ssh -t localhost ssh -t localhost ssh localhost

Have you tried just stacking the ssh commands like ssh -t localhost ssh localhost be sure to add the -t option for each hop except the last one ssh -t localhost ssh -t localhost ssh localhost

这篇关于SSH 通过多个主机执行另一个 ssh 会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆