SSH through multiple hosts to execute another ssh

2020-06-30 03:54发布

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

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.

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.

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.

Thanks in advance!

标签: ssh tunnel
2条回答
啃猪蹄的小仙女
2楼-- · 2020-06-30 04:06

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

查看更多
一夜七次
3楼-- · 2020-06-30 04:33

Maybe try VNC? With the right setup/port forwarding, you wouldn't have to jump from 1 PC to the next.

查看更多
登录 后发表回答