安全地暴露内网服务

通过创建一个只有授权用户能够访问的 SSH 服务代理,实现内网服务的安全暴露。

某些内网服务,如果直接暴露在公网上,可能存在安全风险。使用 stcp(secret tcp) 类型的代理可以让您安全地将内网服务暴露给经过授权的用户,这需要访问者也部署 frpc 客户端。

步骤

  1. 配置 frps.toml

    在 frps.toml 文件中添加以下内容:

    bindPort = 7000
        
  2. 部署 frpc 客户端并配置

    在需要将内网服务暴露到公网的机器上部署 frpc,并创建如下配置:

    serverAddr = "x.x.x.x"
        serverPort = 7000
        
        [[proxies]]
        name = "secret_ssh"
        type = "stcp"
        # 只有与此处设置的 secretKey 一致的用户才能访问此服务
        secretKey = "abcdefg"
        localIP = "127.0.0.1"
        localPort = 22
        
  3. 在访问者机器上部署并配置 frpc

    在想要访问内网服务的机器上也部署 frpc,并创建如下配置:

    serverAddr = "x.x.x.x"
        serverPort = 7000
        
        [[visitors]]
        name = "secret_ssh_visitor"
        type = "stcp"
        # 要访问的 stcp 代理的名字
        serverName = "secret_ssh"
        secretKey = "abcdefg"
        # 绑定本地端口以访问 SSH 服务
        bindAddr = "127.0.0.1"
        bindPort = 6000
        
  4. 通过 SSH 访问内网机器

    使用以下命令通过 SSH 访问内网机器,假设用户名为 test:

    ssh -o Port=6000 test@127.0.0.1
        
最后修改 November 15, 2023: fix 404 (#71) (626ce4d)

Safely expose intranet services

By creating an SSH service agent that can only be accessed by authorized users To achieve security exposure of internal network services.

Some internal network services may pose security risks if they are directly exposed to the public network. Use stcp (secret TCP) Type of Agent It allows you to securely expose internal network services to authorized users, which requires a Visitor Also deploy frpc Client.

Steps

  1. Configuration frps.toml

    Add the following to the frps.toml file:

    bindPort = 7000
        
  2. Deployment frpc Client并Configuration

    Deploy on machines that need to expose private network services to the public network. Frpc, and create the following Configuration:

    serverAddr = "x.x.x.x"
        serverPort = 7000
        
        [[proxies]]
        name = "secret_ssh"
        type = "stcp"
        # Only users who are consistent with the secretKey set here can access this service
        secretKey = "abcdefg"
        localIP = "127.0.0.1"
        localPort = 22
        
  3. Deploy and configure frpc on the Visitor machine

    Deploy on machines that want to access internal network services as well Frpc and create the following Configuration:

    serverAddr = "x.x.x.x"
        serverPort = 7000
        
        [[visitors]]
        name = "secret_ssh_visitor"
        type = "stcp"
        # name of the stcp Agent to be accessed
        serverName = "secret_ssh"
        secretKey = "abcdefg"
        # bind local port to access SSH service
        bindAddr = "127.0.0.1"
        bindPort = 6000
        
  4. Access the private network machine through SSH

    Use the following command Access the private network machine through. SSH, assuming the user name is test:

    ssh -o Port=6000 test@127.0.0.1
        
Last modified November 15, 2023: fix 404 (#71) (626ce4d)