Skip to content

Instantly share code, notes, and snippets.

@641i130
Created August 19, 2023 05:33
Show Gist options
  • Save 641i130/cf89e2677ea23f28f4f814ef0192c491 to your computer and use it in GitHub Desktop.
Save 641i130/cf89e2677ea23f28f4f814ef0192c491 to your computer and use it in GitHub Desktop.

Revisions

  1. 641i130 created this gist Aug 19, 2023.
    14 changes: 14 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # MC Port Tunnel SSH Service

    Usecase -> not able to port forward in your network.

    **Assumptions:**
    12345 is the mc server's port that its opening on the remote server (25565).
    User `mc` is the user on the minecraft server.
    User `minecraft` is the user on the cloud SSH server.

    If you have fail2ban installed, make sure to add the following to `/etc/fail2ban/jail.local`:
    ```
    [DEFAULT]
    ignoreip = (public ip address of the private network its running on; the one you're tunneling out of)
    ```
    15 changes: 15 additions & 0 deletions mc_tunnel.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    [Unit]
    Description=SSH Port tunnel for minecraft
    After=network.target

    [Service]
    Type=simple
    User=mc
    Group=mc
    ExecStart=/usr/bin/ssh -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -n -N -R 12345:10.3.0.95:25565 [email protected]
    Restart=always
    RestartSec=20
    KillMode=mixed

    [Install]
    WantedBy=multi-user.target
    3 changes: 3 additions & 0 deletions sshd_config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Match User minecraft
    AllowTcpForwarding yes
    GatewayPorts yes