Vultr Startup Scripts Quickstart Guide

Updated on February 8, 2022
Vultr Startup Scripts Quickstart Guide header image

You can add startup scripts to your Vultr cloud server instances in the Customer Portal or through the Vultr API. This guide explains the different types of scripts available at Vultr and how to use them.

Script Types

Vultr supports several types of startup scripts:

How to use Boot Scripts

Boot scripts are standard shell scripts executed by your server instance. The server's operating system determines where the script is stored, what script interpreter is used, and where the log output is saved.

Boot Scripts on *BSD

  • The script is saved to /tmp/firstboot.exec.
  • It is executed with /bin/sh as the root user.
  • The output is saved to /tmp/firstboot.log.

Boot Scripts on Windows

  • The script is saved to C:\image\firstboot.cmd.
  • It is executed with cmd.exe as the Administrator.
  • The output is saved to C:\image\firstboot.log

Boot scripts use a two-step process. First, you add a script to your account, then assign that script to an instance.

Add a Script

You can add a script to your account through the customer portal:

  1. Navigate to the Add Startup Script page.
  2. Choose a name for your script.
  3. Select Boot for the type.
  4. Replace the example with your script.
  5. Click Add Script.

You can also add a script to your account through the Vultr API with the create-startup-script endpoint.

Assign the Script

After adding the script, you can assign it when you deploy a new instance through the customer portal. Choose your script from the list, or if you need to add a new script, use the Manage link or the Add New button.

Screenshot of customer portal with a startup script selected

You can also assign a script to a new instance with the Vultr API by passing the script_id to the create-instance endpoint.

BSD Boot Script Example: Query Instance Metadata

Boot scripts may query the Vultr Metadata API to discover information about the instance. This example script logs the server's metadata to /tmp/metadata.json during the first boot.


curl -o /tmp/metadata.json

This could be useful if you parse the JSON metadata with tools such as jq, Python, sed, awk, or grep. For example, you could use the metadata to discover your IP address and generate configuration files automatically on the first boot.

BSD Boot Script Example: Pre-Load SSH Public Key

This example installs a public key for SSH authentication. Replace "ssh-rsa AA..." with your SSH public key.


mkdir -p /root/.ssh
chmod 700 /root/.ssh
echo ssh-rsa AA... > /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

Other common uses for boot scripts are installing software, running updates, and adding users. It's possible to fully configure a system with boot scripts with a little creativity.

How to use iPXE Scripts

An iPXE script automates the installation of a custom operating system. An iPXE script is executed by iPXE each time the server starts if no operating system is installed on the server's disk. After an operating system is installed, iPXE scripts do not run.


  • Must be a valid iPXE script.
  • You can select an iPXE script when deploying an instance under the Upload ISO option on the deploy page.

Screenshot of the Vultr server deploy page with the iPXE feature shown

See the article iPXE Boot Feature for more information.

iPXE Script Example: Boot CoreOS

This is an example that boots CoreOS. You need to add your SSH key before this will work.


set base-url

kernel ${base-url}/coreos_production_pxe.vmlinuz sshkey="ssh-rsa AAAA..." cloud-config-url=
initrd ${base-url}/coreos_production_pxe_image.cpio.gz

More Information

  • The Vultr API offers several endpoints to manage boot scripts.
    • Create a new startup script.
    • Get information for a startup script.
    • List all startup scripts.
    • Update a startup script.
    • Delete a startup script.