ssh remote forward 監聽 0.0.0.0 端口;How to make SSH remote port forward that listens 0.0.0.0

今天使用ssh轉發內網服務的時候,發現remote forward 轉發到遠程,監聽的端口都是localhost。

之前還沒發現這種情況,因爲都是在所轉發的目的主機使用服務。今天,我進行轉發內網私有云服務,到網關主機的時候,不管怎麼設置都是監聽localhost。

而我的需求是能夠監聽0.0.0.0地址,接收通過域名和ip的方式的訪問。

通過查找網絡,我很快發現瞭解決方案:

Enable GatewayPorts in sshd_config (by default it is disabled).
Enabling it will instruct sshd to allow remote port forwardings to bind to a non-loopback address.
AskUbuntu has a similar question about Reverse Port Tunneling that goes into more details.

主要思路是,修改sshd配置文件 的 GatewayPorts 爲yes, 並重啓sshd 服務即可。我想這應該是sshd默認的一種安全保護。

修改後,查看服務器端口號如下:

可見,修改生效。前面的*,表示當前接收所有目的ip的,相應端口的數據包;祝你使用愉快!

參考鏈接:

How to make SSH remote port forward that listens 0.0.0.0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章