Skip to content

Instantly share code, notes, and snippets.

@641i130
Created August 19, 2023 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 641i130/cf89e2677ea23f28f4f814ef0192c491 to your computer and use it in GitHub Desktop.
Save 641i130/cf89e2677ea23f28f4f814ef0192c491 to your computer and use it in GitHub Desktop.
Minecraft SSH Port Tunnel

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)
[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 minecraft@mc.domain.com
Restart=always
RestartSec=20
KillMode=mixed
[Install]
WantedBy=multi-user.target
Match User minecraft
AllowTcpForwarding yes
GatewayPorts yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment