Skip to content

Get started

Import an SSH key, launch an instance that allows SSH, and log in to it, from the console or the API.

Updated View as Markdown

This guide launches an Ubuntu instance with a public IPv4 address and logs in to it with SSH.

Before you start

  • Permissions on the project: ComputeFullAccess, BlockstoreFullAccess, NetworkFullAccess and FirewallFullAccess, with ReadOnlyAccess or ImagesReadOnlyAccess, cover everything here (or the root user). See IAM.

  • An SSH key pair on your computer. To make one:

    ssh-keygen -t ed25519 -f ~/.ssh/ezgh -C laptop
  1. Import your public key. Open Compute, then SSH keys, and choose Add SSH key. Paste the contents of ~/.ssh/ezgh.pub, or choose the file. The name is filled in from the key’s comment.

  2. Open the launch page. Choose Instances, then Launch instance.

  3. Choose what to launch.

    • Image: Ubuntu, version 24.04 LTS.
    • Instance type: a type from the list. Shared and Dedicated switch between CPU families.
    • SSH keys: check your key.
    • Network & firewall: check Public IPv4 address. Under Allow SSH from, keep Anywhere: the console attaches a firewall named ssh-anywhere (creating it the first time) that allows TCP port 22 from any IPv4 or IPv6 address, beside the project’s default firewall.
    • Storage: the root volume’s size defaults to 20 GiB, or the image’s minimum if that’s larger.
  4. Launch. Choose Launch instance. The instance’s page opens while it’s Pending; it’s ready when its state is Running.

  5. Log in. The instance’s page shows its IPv6 address and Public IPv4. Ubuntu’s user is ubuntu:

    ssh -i ~/.ssh/ezgh ubuntu@203.0.113.10

Set an API key and the organization’s and project’s UUIDs (on their pages in the console):

export EZGH_API_KEY=…  ORG_ID=…  PROJECT_ID=…
export P="v1/organizations/$ORG_ID/projects/$PROJECT_ID"
  1. Import your public key with ImportSshKey:

    SSH_KEY_ID=$(jq -n --arg key "$(cat ~/.ssh/ezgh.pub)" '{name: "laptop", publicKey: $key}' |
      curl -sS -X POST "https://compute-api.ezghcloud.com/$P/ssh-keys" \
        -H "Authorization: Bearer $EZGH_API_KEY" -H "Content-Type: application/json" -d @- | jq -r .slug)
  2. Choose an instance type from ListInstanceTypes:

    curl -sS "https://compute-api.ezghcloud.com/v1/organizations/$ORG_ID/instance-types" \
      -H "Authorization: Bearer $EZGH_API_KEY" | jq -r '.instanceTypes[] | select(.status == "active") | .name'
    export TYPE=…   # one of them
  3. Create a firewall that allows SSH with CreateFirewall. The rules you give replace the default outbound rules, so include those too:

    SSH_FW=$(curl -sS -X POST "https://firewall-api.ezghcloud.com/$P/firewalls" \
      -H "Authorization: Bearer $EZGH_API_KEY" -H "Content-Type: application/json" -d '{
        "name": "ssh-anywhere",
        "rules": [
          { "direction": "inbound", "protocol": "tcp", "ports": { "from": 22, "to": 22 }, "peer": { "cidr": "0.0.0.0/0" } },
          { "direction": "inbound", "protocol": "tcp", "ports": { "from": 22, "to": 22 }, "peer": { "cidr": "::/0" } },
          { "direction": "outbound", "protocol": "all", "peer": { "cidr": "0.0.0.0/0" } },
          { "direction": "outbound", "protocol": "all", "peer": { "cidr": "::/0" } }
        ] }' | jq -r .slug)
  4. Launch with CreateInstance. The primary network interface gets a public IPv4 address, and leaving out firewallIds attaches the project’s default firewall:

    OP=$(curl -sS -X POST "https://compute-api.ezghcloud.com/$P/instances" \
      -H "Authorization: Bearer $EZGH_API_KEY" -H "Content-Type: application/json" \
      -H "Idempotency-Key: $(uuidgen)" -d "{
        \"name\": \"web-1\",
        \"instanceType\": \"$TYPE\",
        \"image\": \"linux/ubuntu:24.04\",
        \"sshKeyIds\": [\"$SSH_KEY_ID\"],
        \"networkInterfaces\": [ { \"ipv4\": true } ]
      }")
    INSTANCE=$(echo "$OP" | jq -r .target.id)

    The answer is 202 with a CreateInstance operation. Poll the instance with GetInstance until its status is running.

  5. Attach the SSH firewall to the instance’s primary interface with AttachFirewall:

    ENI=$(curl -sS "https://compute-api.ezghcloud.com/$P/instances/$INSTANCE" \
      -H "Authorization: Bearer $EZGH_API_KEY" | jq -r .primaryNetworkInterfaceId)
    curl -sS -X POST "https://firewall-api.ezghcloud.com/$P/firewalls/$SSH_FW/attachments" \
      -H "Authorization: Bearer $EZGH_API_KEY" -H "Content-Type: application/json" \
      -d "{\"interfaceId\": \"$ENI\"}"
  6. Log in. The interface has the addresses (GetNetworkInterface):

    curl -sS "https://network-api.ezghcloud.com/$P/network-interfaces/$ENI" \
      -H "Authorization: Bearer $EZGH_API_KEY" | jq '{ipv6Address, ipv4: .ipv4Address.address}'
    ssh -i ~/.ssh/ezgh ubuntu@203.0.113.10

The ezgh CLI uses your signed-in profile’s organization and project, or --org and --project.

  1. Import your public key:

    ezgh compute ssh-keys create laptop --public-key ~/.ssh/ezgh.pub
  2. Choose an instance type and a volume type for the root volume:

    ezgh compute instance-types list
    ezgh compute volume-types list
  3. Create a firewall that allows SSH. A new firewall allows all outbound traffic; add inbound TCP 22 from any IPv4 and IPv6 address:

    ezgh compute firewalls create ssh-anywhere
    ezgh compute firewalls rules add ssh-anywhere --direction inbound --protocol tcp --ports 22 --cidr 0.0.0.0/0
    ezgh compute firewalls rules add ssh-anywhere --direction inbound --protocol tcp --ports 22 --cidr ::/0
  4. Launch and wait until it’s running. The primary interface gets a public IPv4 address and the project’s default firewall:

    ezgh compute instances launch web-1 --instance-type <type> --root-volume-type <volume type> \
      --image linux/ubuntu:24.04 --ssh-key laptop --ipv4 --wait
  5. Attach the SSH firewall to the instance’s primary interface:

    ENI=$(ezgh compute instances get web-1 -o json | jq -r .primaryNetworkInterfaceId)
    ezgh compute firewalls attachments attach ssh-anywhere "$ENI"
  6. Log in with the interface’s addresses:

    ezgh compute network-interfaces get "$ENI"
    ssh -i ~/.ssh/ezgh ubuntu@203.0.113.10

Each image has its own login user. If SSH doesn’t connect, check the instance’s console output for cloud-init’s progress.

Clean up

Terminating the instance deletes its root volume and the network interface and IPv4 address the launch made. In the console, open the instance and choose Terminate; with the API, call TerminateInstance; with the CLI, ezgh compute instances terminate web-1. The SSH key and the ssh-anywhere firewall stay for your next launch.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close