ssh -L 转发多个端口 [英] ssh -L forward multiple ports

查看:410
本文介绍了ssh -L 转发多个端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在运行一堆:

sudo ssh -L PORT:IP:PORT root@IP

其中 IP 是安全机器的目标,PORT 代表我要转发的端口.

where IP is the target of a secured machine, and PORT represents the ports I'm forwarding.

这是因为我使用了很多应用程序,如果没有此转发,我将无法访问这些应用程序.执行此操作后,我可以通过 localhost:PORT 访问.

This is because I use a lot of applications which I cannot access without this forwarding. After performing this, I can access through localhost:PORT.

现在出现的主要问题是,我实际上有 4 个必须转发的端口.

The main problem occured now that I actually have 4 of these ports that I have to forward.

我的解决方案是打开 4 个 shell 并不断向后搜索我的历史记录以准确查找需要转发的端口等,然后运行此命令 - 每个 shell 中一个(必须填写密码等).

My solution is to open 4 shells and constantly search my history backwards to look for exactly which ports need to be forwarded etc, and then run this command - one in each shell (having to fill in passwords etc).

如果我能做这样的事情就好了:

If only I could do something like:

sudo ssh -L PORT1+PORT2+PORT+3:IP:PORT+PORT2+PORT3 root@IP

那已经很有帮助了.

有没有办法让这件事变得更容易?

Is there a way to make it easier to do this?

推荐答案

-L 选项可以在同一命令中多次指定.每次都有不同的端口.IE.ssh -L localPort0:ip:remotePort0 -L localPort1:ip:remotePort1 ...

The -L option can be specified multiple times within the same command. Every time with different ports. I.e. ssh -L localPort0:ip:remotePort0 -L localPort1:ip:remotePort1 ...

这篇关于ssh -L 转发多个端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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