Skip to content

Instantly share code, notes, and snippets.

@641i130
Created August 19, 2023 05:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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