通過使用 tcpmux 類型的代理,您可以實現(xiàn)多個 SSH 服務(wù)通過同一端口進(jìn)行暴露。這種方法還適用于任何支持 HTTP Connect 代理連接方式的客戶端,以實現(xiàn)端口的復(fù)用。
bindPort = 7000
tcpmuxHTTPConnectPort = 5002
serverAddr = "x.x.x.x"
serverPort = 7000
[[proxies]]
name = "ssh1"
type = "tcpmux"
multiplexer = "httpconnect"
customDomains = ["machine-a.example.com"]
localIP = "127.0.0.1"
localPort = 22
serverAddr = "x.x.x.x"
serverPort = 7000
[[proxies]]
name = "ssh2"
type = "tcpmux"
multiplexer = "httpconnect"
customDomains = ["machine-b.example.com"]
localIP = "127.0.0.1"
localPort = 22
使用以下命令:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:%h:%p,proxyport=5002' test@machine-a.example.com
要訪問內(nèi)網(wǎng)機(jī)器 B,只需更改域名,假設(shè)用戶名仍然為 test:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:%h:%p,proxyport=5002' test@machine-b.example.com
通過按照以上步驟進(jìn)行配置,您可以實現(xiàn)多個 SSH 服務(wù)復(fù)用同一端口,以便在具有公網(wǎng) IP 的機(jī)器上進(jìn)行訪問。
更多建議: