FRP远程连接

前言

通过frp和跳板机完成局域网服务器访问。工具地址:https://github.com/fatedier/frp

在这里插入图片描述

配置frp过程

  1. 下载frp工具,下载地址如下:

    https://github.com/fatedier/frp/releases

    这里我选择了v0.57.0

  2. 解压到本地路径

    tar -zxvf xxxxxx.tar.gz
    
  3. 配置服务器端和客户端,这里直接从官网copy过来一份:

    # 1. Modify frps.toml on server A by setting the bindPort for frp clients to connect to:
    # frps.toml
    bindPort = 7000
    
    # 2. Start frps on server A:
    ./frps -c ./frps.toml
    
    # 3. Modify frpc.toml on server B and set the serverAddr field to the public IP address of your frps server:
    # frpc.toml
    serverAddr = "x.x.x.x"
    serverPort = 7000
    
    [[proxies]]
    name = "ssh"
    type = "tcp"
    localIP = "127.0.0.1"
    localPort = 22
    remotePort = 6000
    # Note that the localPort (listened on the client) and remotePort (exposed on the server) are used for traffic going in and out of the frp system, while the serverPort is used for communication between frps and frpc.
    
    # 4. Start frpc on server B:
    ./frpc -c ./frpc.toml
    
    # 5. To access server B from another machine through server A via SSH (assuming the username is test), use the following command:
    ssh -oPort=6000 test@x.x.x.x
    
  4. 配置云服务器的安全组端口入站和出站规则,具体查阅网上资料吧

更多信息见官网:https://github.com/fatedier/frp

设置frpc开机自启

  1. 添加systemd配置文件

    vim /usr/lib/systemd/system/frp.service
    
  2. 添加如下内容:

    [Unit]
    Description=The nginx HTTP and reverse proxy server
    After=network.target
    
    [Service]
    Type=simple
    Restart=on-failure
    RestartSec=5s
    ExecStart=/opt/frp_0.57.0_linux_amd64/frpc -c /opt/frp_0.57.0_linux_amd64/frpc.toml # 这里根据实际情况修改
    ExecReload=/opt/frp_0.57.0_linux_amd64/frpc reload -c /opt/frp_0.57.0_linux_amd64/frpc.toml # 根据实际情况修改
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=process
    PrivateTmp=true
    StandardOutput=syslog
    StandardError=inherit
    
    [Install]
    WantedBy=multi-user.target
    
  3. 设置开机启动

    systemctl daemon-reload
    systemctl enable frp
    
  4. 手动启动

    systemctl start frp
    

常见问题

记录了我自己在安装过程中遇到的问题,如下:

问题: Connection closed by remote host
解决

sudo apt update && sudo apt upgrade && sudo apt install openssh-server
参考: https://github.com/fatedier/frp/issues/2064

问题:Host key verification failed.
解决:

删除本地的know_host
参考:https://blog.csdn.net/Doitm/article/details/127907684

参考资料

  1. frp设置开机自启服务
  2. frp开机启动

相关推荐

  1. SSH远程连接

    2024-04-24 15:02:04       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-24 15:02:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-24 15:02:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-24 15:02:04       82 阅读
  4. Python语言-面向对象

    2024-04-24 15:02:04       91 阅读

热门阅读

  1. 【无标题】

    2024-04-24 15:02:04       34 阅读
  2. ES8导出的mapping批量修改索引名

    2024-04-24 15:02:04       30 阅读
  3. GNU nano编辑文件,保存文件

    2024-04-24 15:02:04       28 阅读
  4. 【matlab】灰度图压缩

    2024-04-24 15:02:04       29 阅读
  5. ros的master和apollo的cyber的异同

    2024-04-24 15:02:04       29 阅读
  6. windows10 下 wsl + ubuntu + cups 安装使用

    2024-04-24 15:02:04       32 阅读
  7. 从零开始的机器学习之旅:探索Sklearn基础教程

    2024-04-24 15:02:04       36 阅读
  8. PHP中的错误处理机制是怎样的?

    2024-04-24 15:02:04       76 阅读
  9. 如何根据元素的位置关系来调整 CSS 样式

    2024-04-24 15:02:04       31 阅读
  10. PostCSS概述

    2024-04-24 15:02:04       32 阅读