Custom scripts


Coming soon to the new Maxihost Experience

Custom Scripts is not yet available on the new Maxihost Experience. We're working on adding this feature soon.

Custom Scripts are scripts that use the cloud-config format, designed to be run by the cloud-init process. These scripts are generally used for the initial configuration of a server and run on the first boot.

Put simply, deploying a server with a custom script allows you to run arbitrary commands and change several aspects of the server during provisioning.

Here are a few examples of what you can do with a very simple custom script:

  • Change user passwords
  • Check in the device on your infrastructure
  • Notify people or systems that a new device has been deployed
  • Install packages and dependencies

File format

UNIX-like systems

If you're using a UNIX-like O.S. such as Linux, your scripts must be written using the YAML file format, which uses whitespace and new-lines to delimit lists, associative arrays, and values.

These files are generally fairly intuitive and easy to understand, but there are a few things you need to keep in mind when using them. Here is a good getting started guide from the guys at Ansible that can help.


Always validate your YAML code. Google YAML validator if you don't have a linter on your IDE, but remember never to add sensitive data.

Windows systems

For Windows images, you'll have to use the cloud-baseinit convention. This is just a fancy way of saying that your custom scripts will have to be written as if you were using Powershell. Here's a straightforward example:

mkdir c:/test
New-Item c:/test/test.txt
Set-Content c:/test/test.txt 'Hello World'

Adding a custom script

  1. Go to Project Settings > Custom Scripts
  2. The name of your script needs to be preceded by a number and a dash. We use this to define the order of the scripts that you select. For instance, a script named 01-Script will run before 02-Script because 01 takes execution precedence over 02.
  3. Click on add and proceed with deploying your server.

Building a custom script


Variables can be used to automatically replace placeholders on your custom scripts with data that is only available during or right after a deployment.

Variables are wrapped in double curly brackets ({{ VAR }}). Here are the available variables that can be used by any Custom Script.




The normalized hostname.


Root password of the deployed server.


Distro name. Examples: ubuntu, centos, windows.

{{ MACADR }}

MAC Address.

{{ WANIP }}

WAN IP address.

{{ SSH }}

An array of the SSH keys you chose to deploy your server with, if any.


Here's an example of a custom script that uses the {{ PASSWORD }} variable to change the root password and allow for root logins.

user: root
chpasswd: {expire: false}
password: {{ PASSWORD }}
disable_root: false
ssh_pwauth: true
- echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
- systemctl restart ssh

You can find more great examples on cloud-init's docs.

Did this page help you?