User data is a key/value store you can use to provide your instance with introspective data.
As an example of use, Scaleway images contain the scw-generate-ssh-keys script, which generates the SSH server’s host keys, then stores their fingerprints as user data under the ssh-host-fingerprints key.
This way, before connecting to the instance using SSH, one can query the fingerprints to ensure that the remote host is the expected one, thus avoiding any man-in-the-middle attack.
There are two ways of accessing user data:
- From within a running Instance, by requesting the Metadata API at http://169.254.42.42/user_dataOpen in new context (or http://[fd00:42::42]/user_data using IPv6).
The
scaleway-ecosystempackage, installed by default on all OS images provided by Scaleway, ships with thescw-userdatahelper command that allows you to easily query the user data from the instance. For security reasons, viewing and editing user data is only allowed to queries originating from a port below 1024 (by default, only the super-user can bind to ports below 1024). To specify the source port with cURL, use the--local-portoption (e.g.curl --local-port 1-1023 http://169.254.42.42/user_data). - From the Instance API by using the methods described below.
List user data
List all user data keys registered on a specified Instance.
path Parameters
zoneThe zone you want to target
server_idUUID of the Instance.
List user data › Responses
user_dataGet user data
Get the content of a user data with the specified key on an Instance.
path Parameters
zoneThe zone you want to target
server_idUUID of the Instance.
keyKey of the user data to get.
Get user data › Responses
namecontent_typecontentDelete user data
Delete the specified key from an Instance's user data.
path Parameters
zoneThe zone you want to target
server_idUUID of the Instance.
keyKey of the user data to delete.
Delete user data › Responses
Add/set user data
Add or update a user data with the specified key on an Instance.
path Parameters
zoneThe zone you want to target
server_idUUID of the Instance.
keyKey of the user data to set.