简体   繁体   English

如何正确使用 ssh 端口转发

[英]How to use ssh portforwarding correctly

On my Pc i got a service which runs on port 51069. I want that this service is reachable with port 80. I tried this comand在我的 PC 上,我有一个在端口 51069 上运行的服务。我希望该服务可以通过端口 80 访问。我试过这个命令

ssh -L 51069:localhost:80 localhost

But it not works, when i ask with my browser for localhost i get not the web service behind 51069.但它不起作用,当我用浏览器询问本地主机时,我得到的不是 51069 后面的 Web 服务。

You have the ports the wrong way round.你有错误的端口。 You want to forward traffic on port 80 to 51069 so it should be您想将端口 80 上的流量转发到 51069,所以它应该是

ssh -L 80:localhost:51069 localhost

HOWEVER, you need root to be able to forward privileged ports (<= 1024) so you would have to ssh locally as root which might not be a great idea.但是,您需要 root 才能转发特权端口(<= 1024),因此您必须以 root 身份在本地进行 ssh,这可能不是一个好主意。

I'd personally use iptables for this: How to do local port forwarding with iptables我个人为此使用 iptables: How to do local port forwarding with iptables

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM