I worked out how to start a java Minecraft server using Siri shortcuts on a Linux/Ubuntu server!
If you want to learn how keep on reading. If you want to see how it turns out, check out the next two images. Click the second image to see an animation of this running in the terminal.
How to do this
I’m going to assume that you already have a Minecraft server running on an ssh-enabled server on your local network, or in the cloud. If it’s running in the cloud, this may be less useful unless your server needs to be restarted regularly.
If you don’t know how to set up a Minecraft server, this is the official wiki page explaining how to do it:
In my setup, I run my Minecraft Server for Java on my Ubuntu Server Edition machine in my house. When the power goes off and on again, the Minecraft server doesn’t automatically start as a service (I prefer to start it manually).
In my last house, this happened frequently, so I created a start Minecraft server script to do this quickly.
The server part
- Create a new file called
start-minecraft.shin the same folder as your Minecraft server jar file
- Paste in the script from below
- Update the location of the folder in “# step 1” of the script to wherever your Minecraft folder is
- For “# step 2” on the script, change server.jar to whatever your server jar file is called
- Save the script file
- Then make the file executable by running
chmod +x start-minecraft.sh
#/bin/bash cd ~/minecraft #step 1 java -Xmx4096M -Xms4096M -jar server.jar nogui #step 2
It’s important that this file is in the same directory as your Minecraft jar file.
Now we need to create the script that Siri will run.
- In your home directory, create a file called
- Paste in the code from below
- Update # step 1 to point to the start-minecraft.sh file in your Minecraft directory.
#/bin/bash screen -S Minecraft_Server -d -m sh ~/minecraft/start-minecraft.sh # step 1
You will now need to install a command-line utility called screen. screen allows us to start the Minecraft server in its own window, without it stopping after Siri finished running the command.
For me, on Ubuntu, I used
sudo apt install screen. This may be different on your operating system. This link explains how to do this:
You will also need to make this file executable using
chmod +x siri-start-minecraft.sh
In the Siri Shortcuts app
- Open the Shortcuts app that comes pre-installed on iOS 13
- Tap “Create Shortcut”
- Tap “Add Action”
- Search for ssh and choose “Run Script Over SSH”
- Tap “Show More”
- Enter the IP address or host of your ssh-enabled Minecraft server
- Port 22 is the default port for SSH
- Type in your username for the Linux server (Not your Minecraft username)
- (A) If you log in with a password choose password and type this in.
(B) If using a ssh key (as I do), choose SSH Key. You can share this generated key with yourself by tapping on it and pressing share. You need to save this text and append it to the bottom of your ~/.ssh/authorized_keys file. You can easily do this running the following in your terminal on the server:
echo "contents of the copied text" >> ~/.ssh/authorized_keys
- In the Script section at the bottom, we can tell the command to execute over ssh. In our case,
- Tap Next in the top right
- Give the shortcut a name such as Start Minecraft Server
- Tap on the command or say “Hey Siri Start Minecraft Server”
- The first time you do this you may be promoted to allow the host for the first time. Tap ok or yes when asked. This is normal.
Check if it worked
- ssh into your Linux server and run
- You should see one of the instances of screen called “Minecraft_Server”
- You can connect to it to enter commands using
screen -r Minecraft_Server
- To disconnect from screen without closing the server, you have to enter the following key sequence:
ctrl a d