2023 The frp Authors 保留所有权利
中文|English
在具有公网 IP 的机器上部署 frps
修改 frps.toml 文件以包含以下内容(这里使用了最简化的配置):
bindPort = 7000
tcpmuxHTTPConnectPort = 5002
在内网机器 A 上部署 frpc
创建 frpc 配置文件,例如 frpc.ini,然后将以下内容添加到配置文件中:
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
在内网机器 B 上部署另一个 frpc
创建 frpc 配置文件,例如 frpc.toml,然后将以下内容添加到配置文件中:
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 ProxyCommand 访问内网机器 A
使用 SSH ProxyCommand 访问内网机器 A,假设用户名为 test。使用以下命令:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-a.example.com:22,proxyport=5002' test@machine-a
要访问内网机器 B,只需更改域名,假设用户名仍然为 test:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-b.example.com:22,proxyport=5002' test@machine-b
通过按照以上步骤进行配置,您可以实现多个 SSH 服务复用同一端口,以便在具有公网 IP 的机器上进行访问。
Deploy frps on machines with public IP
Modify frps.toml The file contains the following content (using the simplified Configuration here):
bindPort = 7000
tcpmuxHTTPConnectPort = 5002
Deploy frpc on internal machine A
Create a frpc Configuration file, for example Frpc.ini, then add the following content to the Configuration file:
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
Deploy another frpc on internal machine B
Create a frpc Configuration file, for example Frpc.toml, then add the following content to the Configuration file:
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
Accessing internal machine A through SSH ProxyCommand
Use SSH ProxyCommand to access internal machine A, assuming the username is Test. Use the following command:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-a.example.com:22,proxyport=5002' test@machine-a
To access private network machine B, simply change the domain name, assuming that the user name is still test:
ssh -o 'proxycommand socat - PROXY:x.x.x.x:machine-b.example.com:22,proxyport=5002' test@machine-b
By following the steps above to Configuration, you can implement multiple SSH. Services reuse the same port for access on machines with public network IP。