rack4 CLI cheat sheet

Every rack4 command on one page, by task: servers, SSH, snapshots, the firewall, rDNS, rescue, keys, billing, tickets, JSON and scripting.

This is every rack4 command on one page, grouped by what you want to do. <server> is always a hostname or a server id (srv_…), and every command takes --json for output a script can read.

What you need

Log in and look around

Command Does
rack4 init --token-file ~/.rack4-token Log in and offer to add your SSH public key, step by step
rack4 login < ~/.rack4-token Check a token and save it
rack4 logout Forget the saved token (revoke it in the panel too if it leaked)
rack4 whoami The account the token belongs to
rack4 status Service status, no login needed
rack4 prices Plans and add-ons, monthly and yearly, no login needed
rack4 images The images --image takes
rack4 apps The one-click apps --app takes
rack4 open [<server>] [--print] Open the panel, or a server's page, in your browser
rack4 help The full usage
rack4 version The version you have

Servers

Command Does
rack4 servers List your servers: id, hostname, state, IPv4, plan
rack4 servers show <server> One server, its tags and its recent events
rack4 servers start <server> Start it (also stop, reboot)
rack4 servers label <server> "Website" --tags prod,web Set its display name and tags (--notes-file F for notes, --clear to clear)
rack4 servers create --plan budget --image debian-12 --hostname web-2 --key key_… Order a server (see the options below)
rack4 servers reinstall <server> [--image ubuntu-24.04] Wipe and reinstall; asks you to type the hostname
rack4 servers delete <server> Delete it for good; asks you to type the hostname
rack4 servers addons <server> Its add-ons now and at the next renewal
rack4 servers addons <server> set --ram-gb 2 --apply reboot Change add-ons; asks before it invoices

Options for servers create: --key ID (repeat it), --app ID, --package NAME (repeat it) or --packages a,b, --setup-script FILE (setup scripts), --term month|year, --vcpu N, --ram-gb N, --disk-gb N, --transfer-tb N, --ipv4 N, --root-password generate or --root-password-file FILE, and --idempotency-key K (why). servers reinstall takes --image, --app ID or --no-app, --package, --setup-script and the root password options.

SSH

Command Does
rack4 ssh <server> Run your own ssh as root@ the server's IPv4
rack4 ssh --user deploy <server> Log in as another user (flags go before the server)
rack4 ssh <server> -- -L 8080:localhost:80 Pass options to ssh after --

Snapshots

Command Does
rack4 snapshots <server> List its snapshots: id, name, manual or automatic, state
rack4 snapshots <server> create before-upgrade Take one (a running server shuts down for about a minute)
rack4 snapshots <server> revert before-upgrade Go back to it; asks you to type the hostname
rack4 snapshots <server> rm before-upgrade Delete it; asks you to type the hostname
rack4 snapshots <server> schedule daily --at 3 --tz Europe/Berlin --keep 3 Automatic snapshots (weekly --day sun too)
rack4 snapshots <server> schedule Show the schedule
rack4 snapshots <server> schedule off Turn automatic snapshots off (taken ones are kept)

A server keeps 3 snapshots you take yourself, plus up to 4 automatic ones. Automate snapshots before risky changes wraps these into one command.

Firewall

Command Does
rack4 firewall <server> The rules, numbered, and whether they're applied
rack4 firewall <server> allow tcp 22 from 198.51.100.0/24 Add a rule (deny, and udp, icmp, any too)
rack4 firewall <server> allow tcp 8000-8100 A port range, from anywhere
rack4 firewall <server> rm 2 Remove rule 2
rack4 firewall <server> policy deny Drop anything no rule allows
rack4 firewall <server> set rules.json --policy deny Replace every rule from a file (- reads stdin)

Each change saves with the version it read, so it never overwrites someone else's edit. The panel firewall guide explains the rules.

Reverse DNS, rescue, keys

Command Does
rack4 rdns <server> Reverse DNS for each address
rack4 rdns <server> set 203.0.113.10 mail.example.com Set it (the name must already resolve to the address)
rack4 rdns <server> rm 203.0.113.10 Clear it
rack4 rescue on <server> Boot into rescue mode; prints a one-time root password
rack4 rescue status <server> Where rescue stands
rack4 rescue off <server> Boot from its own disk again
rack4 keys Your SSH keys
rack4 keys add laptop ~/.ssh/id_ed25519.pub Add one (- reads stdin)
rack4 keys rm laptop Remove one; asks you to type its name

Billing and invoices

Command Does
rack4 billing Your credit, what is due in the next 30 days, each server's next charge and your open invoices (rack4 billing upcoming too)
rack4 billing credit Credit movements, newest first, with the balance after each (--limit 500 for more)
rack4 billing topup 25 Add funds: makes a $25.00 top-up invoice and prints its checkout link (--method paypal or btcpay)
rack4 billing profile The name, address and VAT or tax ID your invoices are made out to
rack4 billing profile set --company "Acme Ltd" --tax-id GB123456789 Change only the fields you give (--name, --address1, --address2, --city, --region, --postal-code, --country)
rack4 billing redeem GIFT-7K2M-Q9XD-4HNP-R3TB Redeem a gift card into account credit
rack4 invoices Your invoices, newest first
rack4 invoices show R4-000042 One invoice with its lines

Tickets

Command Does
rack4 tickets Your support tickets
rack4 tickets open --subject "Port 25" --category technical --server web-1 "message" Open one (- reads the message from stdin)
rack4 tickets show <id> One ticket
rack4 tickets reply <id> "message" Reply
rack4 tickets close <id> Close it

Scripting

Use How
JSON instead of a table rack4 --json servers (lists print the array)
No questions --yes (destructive commands otherwise ask for the hostname)
Another token RACK4_TOKEN=vps9_… rack4 servers (wins over the saved login)
Tab completion source <(rack4 completion bash) (also zsh, fish, powershell)

With jq, the running servers' IPv4 addresses, and a loop that waits until a server's action has finished:

bash
rack4 --json servers | jq -r '.[] | select(.state == "running") | .ipv4'
until [ "$(rack4 --json servers show web-1 | jq -r .pendingAction)" = "null" ]; do sleep 5; done

Exit codes: 0 worked, 1 failed (the API's message and request id go to stderr), 2 the command line was wrong.

Check it worked

bash
rack4 whoami && rack4 servers

Your email, then a table of your servers, means the token and the API address are right.

Troubleshooting

rack4: not logged in: run rack4 login (or set RACK4_TOKEN). There's no saved token and no RACK4_TOKEN. Run rack4 login < ~/.rack4-token.

rack4: This token does not have the write scope. The token is read-only. Make a read-and-write one for commands that change things.

rack4: no server named "web-1". No server on this account has that hostname. rack4 servers lists the names; on a team, rack4 whoami shows which account the token acts on.

rack4: Too many requests: 60 a minute per token. A loop is calling too fast; each command makes one to three requests. See Rate limits and request ids.

Doing it on Rack4

Every command here works on the plans you can order, and the developer hub links the API and SDK that the CLI is built on.

Ready when you are

Order a server