HomeComputeElastic MetalAPI/CLI
Creating and managing Elastic Metal servers with the CLI
Jump toUpdate content

Creating and Managing Elastic Metal servers with the Scaleway Command Line Interface (CLI)

Reviewed on 12 January 2023Published on 26 May 2021

Scaleway’s Elastic Metal servers provide you with dedicated servers on-demand, with all the benefits of the cloud including flexibility and hourly billing. These servers are great for large workloads, big data, and applications that require increased security and dedicated resources. You can create and manage your Elastic Metal servers from the Scaleway console, via the API or via the Scaleway Command Line Interface (CLI). In this tutorial, you will learn how to use the CLI to create an Elastic Metal server, install an OS and manage the lifecycle of the server.

Scaleway Command Line Interface Overview

The Scaleway Command Line Interface (CLI) allows you to pilot your Scaleway infrastructure directly from your terminal, providing a faster way to administer and monitor your resources. Scaleway CLI is easy to set up and use, and an essential tool for operating efficiently in your cloud environment. The CLI provides many functionalities, including the ability to create and administer Elastic Metal servers.

Security & Identity (IAM):

You may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets
Requirements:

Configuring the CLI

  1. Open a terminal and type the following command to configure the Scaleway CLI on your machine:

    scw init

    If you have already configured the CLI, you will see a message like the following:

    Current config is located at /path/to/config.yaml
    access_key: your-access-key
    secret_key: your-secret-key
    default_organization_id: ID-of-your-organization
    default_project_id: ID-of-your-project
    default_region: your-default-region (fr-par)
    default_zone: your-default-zone (fr-par-1)
    Do you want to override the current config? (Y/n):
  2. Type n and go directly to the Creating an Elastic Metal server step of this tutorial if you do not want to edit your configuration.

    If you have not yet configured the CLI, you will be guided through the configuration process via a series of questions:

    Enter a valid secret-key or an email
  3. Enter either the email address for your account (you will then be asked for your password), or your API Secret Key:

    To improve this tool we rely on diagnostic and usage data.
    Sending such data is optional and can be disabled at any time by running "scw config set send-telemetry=false".
    Do you want to send usage statistics and diagnostics? (Y/n):

    Type y or n.

    To fully enjoy Scaleway CLI we recommend you install autocomplete support in your shell.
    Do you want to install autocomplete? (Y/n):

    Type y or n.

    To enable autocomplete, scw needs to update your shell configuration.
    What type of shell are you using (default: zsh):
  4. Press enter if the default shell type displayed is the one you are using. Otherwise, enter the correct shell type you are using. This should complete the configuration process:

    Initialization completed with success.

Creating an Elastic Metal server

Important:
  • The help info for the zone argument informs you that the default zone is fr-par-2 because Elastic Metal servers are only available in the fr-par-2 zone at the moment. However fr-par-2 is not necessarily the default zone in your configuration. To create a server, you need to either change the default zone in your configuration file (check the location of this file in the output of scw init and change the value for default zone to fr-par-2), or explicitly target the fr-par-2 zone in the commands to create and manage your server.
  • The available server types are the following: GP-BM1-L GP-BM1-M GP-BM1-S HC-BM1-L HC-BM1-S HM-BM1-XL HM-BM1-M.
  1. Type the following command in your terminal to create your Elastic Metal server:

    scw baremetal server create name=name-of-your-server type=GP-BM1-L zone=fr-par-2

    An output similar to the following displays:

    ID 12345678-1234-1234-1234-123456789123
    OrganizationID 12345678-1234-1234-1234-123456789123
    ProjectID 12345678-1234-1234-1234-123456789123
    Name name-of-your-server
    Description -
    UpdatedAt 36 seconds ago
    CreatedAt 36 seconds ago
    Status delivering
    OfferID 12345678-1234-1234-1234-123456789123
    Domain -
    BootType normal
    Zone fr-par-2
    PingStatus unknown
    Tip:
    • For more information on creating an Elastic Metal server, type scw baremetal server create --help in your terminal.
    • You can add additional arguments to your command, such as description to add a description of your Elastic Metal server, or tags.0 to add tags.
  2. Write down the ID of your server, as you will need it in the next steps.

    Tip:
    • Type scw baremetal server list zone=fr-par-2 for a summary of information for your Elastic Metal server, and details for other servers you have previously created.
    • Use the command scw baremetal server get ID-of-your-server zone=fr-par-2 for information about a specific server.

Installing an OS

Note:

You will need the SSH Key ID associated with your account to install your chosen OS on your server.

  1. Type the following command in your terminal to see a list of available OSes:

    scw baremetal os list zone=fr-par-2

    An output with available OSes and their associated IDs displays:

    ID NAME
    82ed3c56-935c-4012-b01f-69070fce1b1d Ubuntu
    0aa99516-52bb-4a7d-b9fe-1adc8478c2e0 Debian
    58bf948f-8b9b-45c2-9ad6-582c26133f9e Rocky Linux
    e8fc12e5-cfcd-434a-a8b0-d5f5141baf91 Ubuntu
    03b7f4ba-a6a1-4305-984e-b54fafbf1681 Ubuntu
    86fd5e3a-b023-4fa8-a3ae-1a194d8cd68c CentOS
    f2aeab5d-6015-4b7c-b4ed-d76e89093621 Debian
    01d6eef6-6b96-47fd-b9f9-3857321abe4f Ubuntu
  2. Write down the ID of the OS you want to install.

  3. Type the following command to display the list of your SSH key’s ID:

    scw account ssh-key list

    You will see an output similar to the following:

    ID NAME CREATED AT UPDATED AT
    your-ssh-key-ID name-of-your-ssh-key 1 week ago 1 week ago
  4. Write down your SSH Key ID as you will need it in the next steps.

  5. Type the following command to install an OS on your Elastic Metal server:

    scw baremetal server install ID-of-your-elastic-metal-server os-id=ID-of-OS-you-want-to-install hostname=hostname-for-your-server ssh-key-ids.0=your-ssh-key-ID zone=fr-par-2
    Note:

    If you have multiple SSH keys, you can use the argument all-ssh-keys=true to install all your SSH keys on the server.

    An output similar to the following displays:

    ID ID-of-your-Elastic-Metal-Server
    OrganizationID ID-of-your-organization
    ProjectID ID-of-your-project
    Name name-of-your-server
    Description -
    UpdatedAt 8 minutes ago
    CreatedAt 11 minutes ago
    Status ready
    OfferID ID-of-the-offer
    IPs.0.ID 12345678-1234-1234-1234-123456789123
    IPs.0.Address 12.345.67.89
    IPs.0.Reverse -
    IPs.0.Version IPv4
    IPs.0.ReverseStatus unknown
    IPs.0.ReverseStatusMessage -
    IPs.1.ID 12345678-1234-1234-1234-123456789123
    IPs.1.Address 1234:123:4567:8:9123:4567:8912:345
    IPs.1.Reverse 12345678-1234-1234-1234-123456789123.fr-par-2.baremetal.scw.cloud
    IPs.1.Version IPv6
    IPs.1.ReverseStatus active
    IPs.1.ReverseStatusMessage -
    Domain 12345678-1234-1234-1234-123456789123.fr-par-2.baremetal.scw.cloud
    BootType normal
    Zone fr-par-2
    Install.OsID ID-of-your-OS
    Install.Hostname hostname-for-your-server
    Install.SSHKeyIDs.0 your-ssh-key-ID
    Install.Status to_install
    PingStatus up
Note:

You can check the status of your server with the command scw baremetal server list zone=fr-par-2.

Using other CLI commands

There are many other functionalities you can access for your Elastic Metal server via the Scaleway CLI. In the following examples, replace your-elastic-metal-server-ID with your server’s ID.

Note:
  • Before powering off your server, we recommend you log into your server as root and execute the halt command to shutdown the OS.
  • Type scw baremetal server get name-of-server-ID zone=fr-par-2 in your terminal if you are not sure what the IP address of your Elastic Metal server is. It will display in the IPs.0.Address field.

Powering on your Server

Type the following command in your terminal:

scw baremetal server start your-elastic-metal-server-ID zone=fr-par-2

The following output displays and you will see “starting” next to the Status field:

ID 12345678-1234-1234-1234-123456789123
OrganizationID 12345678-1234-1234-1234-123456789123
ProjectID 12345678-1234-1234-1234-123456789123
Name name-of-your-server
Description -
UpdatedAt 3 seconds from now
CreatedAt 3 hours ago
Status starting
OfferID 12345678-1234-1234-1234-123456789123
IPs.0.ID 12345678-1234-1234-1234-123456789123
IPs.0.Address 12.345.67.89
IPs.0.Reverse -
IPs.0.Version IPv4
IPs.0.ReverseStatus unknown
IPs.0.ReverseStatusMessage -
IPs.1.ID 12345678-1234-1234-1234-123456789123
IPs.1.Address IPs.1.Address
IPs.1.Reverse IPs.1.Reverse
IPs.1.Version IPv6
IPs.1.ReverseStatus pending
IPs.1.ReverseStatusMessage -
IPs.2.ID IPs.2.ID
IPs.2.Address 51.159.17.32
IPs.2.Reverse IPs.2.Reverse
IPs.2.Version IPv4
IPs.2.ReverseStatus active
IPs.2.ReverseStatusMessage -
Domain your-domain-name
BootType normal
Zone fr-par-2
Install.OsID 12345678-1234-1234-1234-123456789123
Install.Hostname hostname-for-your-server
Install.SSHKeyIDs.0 12345678-1234-1234-1234-123456789123
Install.Status completed
PingStatus up

Powering off your Server

Important:

Before powering off your Elastic Metal server, we recommend you log into your server as root and execute the halt command to shutdown the OS.

Type the following command in your terminal:

scw baremetal server stop your-elastic-metal-server-ID zone=fr-par-2

The following output displays and you will see “stopping” next to the Status field:

ID 12345678-1234-1234-1234-123456789123
OrganizationID 12345678-1234-1234-1234-123456789123
ProjectID 12345678-1234-1234-1234-123456789123
Name name-of-your-server
Description -
UpdatedAt 3 seconds from now
CreatedAt 3 hours ago
Status stopping
OfferID 12345678-1234-1234-1234-123456789123
IPs.0.ID 12345678-1234-1234-1234-123456789123
IPs.0.Address 12.345.67.89
IPs.0.Reverse -
IPs.0.Version IPv4
IPs.0.ReverseStatus unknown
IPs.0.ReverseStatusMessage -
IPs.1.ID 12345678-1234-1234-1234-123456789123
IPs.1.Address IPs.1.Address
IPs.1.Reverse IPs.1.Reverse
IPs.1.Version IPv6
IPs.1.ReverseStatus pending
IPs.1.ReverseStatusMessage -
IPs.2.ID IPs.2.ID
IPs.2.Address 51.159.17.32
IPs.2.Reverse IPs.2.Reverse
IPs.2.Version IPv4
IPs.2.ReverseStatus active
IPs.2.ReverseStatusMessage -
Domain your-domain-name
BootType normal
Zone fr-par-2
Install.OsID 12345678-1234-1234-1234-123456789123
Install.Hostname hostname-for-your-server
Install.SSHKeyIDs.0 12345678-1234-1234-1234-123456789123
Install.Status completed
PingStatus up

Rebooting your Server

Type the following command:

scw baremetal server reboot your-elastic-metal-server-ID zone=fr-par-2

The following output displays and you will see “down” next to the PingStatus field:

ID 12345678-1234-1234-1234-123456789123
OrganizationID 12345678-1234-1234-1234-123456789123
ProjectID 12345678-1234-1234-1234-123456789123
Name name-of-your-server
Description -
UpdatedAt 3 seconds from now
CreatedAt 3 hours ago
Status stopping
OfferID 12345678-1234-1234-1234-123456789123
IPs.0.ID 12345678-1234-1234-1234-123456789123
IPs.0.Address 12.345.67.89
IPs.0.Reverse -
IPs.0.Version IPv4
IPs.0.ReverseStatus unknown
IPs.0.ReverseStatusMessage -
IPs.1.ID 12345678-1234-1234-1234-123456789123
IPs.1.Address IPs.1.Address
IPs.1.Reverse IPs.1.Reverse
IPs.1.Version IPv6
IPs.1.ReverseStatus pending
IPs.1.ReverseStatusMessage -
IPs.2.ID IPs.2.ID
IPs.2.Address 51.159.17.32
IPs.2.Reverse IPs.2.Reverse
IPs.2.Version IPv4
IPs.2.ReverseStatus active
IPs.2.ReverseStatusMessage -
Domain your-domain-name
BootType normal
Zone fr-par-2
Install.OsID 12345678-1234-1234-1234-123456789123
Install.Hostname hostname-for-your-server
Install.SSHKeyIDs.0 12345678-1234-1234-1234-123456789123
Install.Status completed
PingStatus down

Deleting your Server

Important:

This will permanently delete your Elastic Metal server and your data. This action is irreversible.

Type the following command in your terminal:

scw baremetal server reboot your-elastic-metal-server-ID zone=fr-par-2

An output like the following displays and you will see “deleting” next to the Status field:

ID your-elastic-metal-server-ID
OrganizationID your-organization-ID
ProjectID your-project-ID
Name name-of-your-server
Description -
UpdatedAt now
CreatedAt 4 hours ago
Status deleting
OfferID your-offer-ID
Tags.0 -
IPs.1.ID 12345678-1234-1234-1234-123456789123
IPs.1.Address 1234:123:4567:8:9123:4567:8912:345
IPs.1.Reverse 12345678-1234-1234-1234-123456789123.fr-par-2.baremetal.scw.cloud
IPs.1.Version IPv6
IPs.1.ReverseStatus active
IPs.1.ReverseStatusMessage -
Domain 12345678-1234-1234-1234-123456789123.fr-par-2.baremetal.scw.cloud
BootType normal
Zone fr-par-2
Install.OsID ID-of-your-OS
Install.Hostname hostname-for-your-server
Install.SSHKeyIDs.0 your-ssh-key-ID
Install.Status completed
PingStatus down

Enter the following command to make sure that your server has been deleted:

scw baremetal server list zone=fr-par-2

An output similar to the following displays:

12345678-1234-1234-1234-123456789123 name-of-your-server GP-BM1-L stopped
See Also