美文网首页
frp 配置内网穿透、ssh远程访问、systemctl 自启动

frp 配置内网穿透、ssh远程访问、systemctl 自启动

作者: 273123e8cd8a | 来源:发表于2019-02-22 22:54 被阅读0次

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

    1.内网穿透

    1.1 服务器端 VPS 配置

    下载匹配的版本,https://github.com/fatedier/frp/releases

    • 修改 frps.ini 文件:
    # frps.ini
    [common]
    bind_port = 7000
    
    • 启动 frps:
    ./frps -c ./frps.ini
    

    1.2 客户端配置

    • 修改 frpc.ini 文件,假设 frps 所在服务器的公网 IP 为 123.123.1.0;
    # frpc.ini
    [common]
    server_addr = 123.123.1.0
    server_port = 7000
    
    [ssh]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 22
    remote_port = 6000
    
    • 启动 frpc:
    ./frpc -c ./frpc.ini
    

    1.3 远程访问

    ssh root@123.123.1.0 -oPort=6000 
    

    2. 自动启动 frp 服务--使用 systemctl

    • 2.1 新建 frp.service 文件
    sudo nano /lib/systemd/system/frp.service 
    
    • 2.2 写入以下内容,注意区分 服务端客户端
    [Unit]
    Description=frp service
    After=network.target syslog.target
    Wants=network.target
    
    [Service]
    Type=simple
    # 服务端
    ExecStart=/home/ubuntu/frp/frps -c /home/ubuntu/frp/frps.ini
    # 客户端
    # ExecStart=/root/frp/frpc -c /root/frp/frpc.ini
    
    [Install]
    WantedBy=multi-user.target
    
    • 2.3 使用 systemctl 启动服务
    # 启动frp
    sudo systemctl start frp
    # 开机自启动 
    sudo systemctl enable frp
    
    # 重启
    sudo systemctl restart frp
    # 停止
    sudo systemctl stop frp
    # 查看日志
    sudo systemctl status frp
    

    相关文章

      网友评论

          本文标题:frp 配置内网穿透、ssh远程访问、systemctl 自启动

          本文链接:https://www.haomeiwen.com/subject/xfseyqtx.html