Skip to content

Instantly share code, notes, and snippets.

@EspadaV8
Created July 18, 2011 05:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save EspadaV8/1088594 to your computer and use it in GitHub Desktop.
Save EspadaV8/1088594 to your computer and use it in GitHub Desktop.
Simple script to use minecraft over an SSH tunnel
#!/bin/bash
MCLAUNCHER="path/to/MinecraftLauncher.jar"
# Your SSH host, e.g. www.example.com
SSHHOST="<your-ssh-host>"
# Stores the controlmaster file. Need to enable controlpath in the ssh .config file
SOCKCTL="~/.mc-ssh-ctl"
# Opens up an SSH tunnel to the remote server opening port 8080 locally
SSHCMD="ssh -nfN -D 8080 -S ""$SOCKCTL"" ""$SSHHOST"""
# Uses the control file to kill the SSH tunnel when finished with minecraft
SSHEXIT="ssh -S ""$SOCKCTL"" -O exit ""$SSHHOST"""
${SSHCMD}
# sleep for 5 seconds to make sure that the connection has been made
sleep 5
# Loads up Minecraft with the proxy information using the SSH tunnel
java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8080 -Xmx800m -jar "$MCLAUNCHER"
# when finished, quit SSH
${SSHEXIT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment