Enable it
With the server stopped, set these in server.properties and start again:
- enable-rcon=true
- rcon.port=25575, or a port your host assigned
- rcon.password=a long random password
- broadcast-rcon-to-ops=true if you want operators to see RCON commands
Connect with a client
Command-line tools such as mcrcon, and many Discord bots and admin dashboards, speak RCON. Give them the server address, the RCON port and the password, then send commands exactly as you would type them in the console.
Why it must not be public
The RCON protocol is not encrypted. The password and every command travel in plain text, and anyone who gets the password has full console access. Never reuse a password, never post the port and password anywhere, and keep RCON reachable only from the machines that need it. A firewall rule that allows only your bot's IP is the right approach.
You may not need it at all
If you only want to run commands remotely, a hosting panel console already does that over an encrypted connection, with per-user permissions. Use RCON when a specific tool requires it.