Enrollment
Enroll a host
Called by custosd enroll, not by a user. Unauthenticated but rate-limited: the enrollment token is the credential. Custos enforces one active host per machine, keyed on a hash of /etc/machine-id, with prior_host_id as the fallback when that is unavailable.
POST
/
enroll
Enroll a host
curl --request POST \
--url https://custos.example.com/enroll \
--header 'Content-Type: application/json' \
--data '
{
"token": "<string>",
"public_key": "<string>",
"hostname": "<string>",
"encryption_key": "<string>",
"machine_id": "<string>",
"prior_host_id": "<string>",
"ssh_address": "<string>"
}
'import requests
url = "https://custos.example.com/enroll"
payload = {
"token": "<string>",
"public_key": "<string>",
"hostname": "<string>",
"encryption_key": "<string>",
"machine_id": "<string>",
"prior_host_id": "<string>",
"ssh_address": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
token: '<string>',
public_key: '<string>',
hostname: '<string>',
encryption_key: '<string>',
machine_id: '<string>',
prior_host_id: '<string>',
ssh_address: '<string>'
})
};
fetch('https://custos.example.com/enroll', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://custos.example.com/enroll",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'token' => '<string>',
'public_key' => '<string>',
'hostname' => '<string>',
'encryption_key' => '<string>',
'machine_id' => '<string>',
'prior_host_id' => '<string>',
'ssh_address' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://custos.example.com/enroll"
payload := strings.NewReader("{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://custos.example.com/enroll")
.header("Content-Type", "application/json")
.body("{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://custos.example.com/enroll")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"host_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signing_public_key": "<string>"
}Body
application/json
The daemon's Ed25519 identity public key, base64.
The daemon's X25519 public key for sealed sets, base64.
Hash of /etc/machine-id; empty when unavailable, e.g. in containers.
The daemon's previous host id when re-enrolling.
⌘I
Enroll a host
curl --request POST \
--url https://custos.example.com/enroll \
--header 'Content-Type: application/json' \
--data '
{
"token": "<string>",
"public_key": "<string>",
"hostname": "<string>",
"encryption_key": "<string>",
"machine_id": "<string>",
"prior_host_id": "<string>",
"ssh_address": "<string>"
}
'import requests
url = "https://custos.example.com/enroll"
payload = {
"token": "<string>",
"public_key": "<string>",
"hostname": "<string>",
"encryption_key": "<string>",
"machine_id": "<string>",
"prior_host_id": "<string>",
"ssh_address": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
token: '<string>',
public_key: '<string>',
hostname: '<string>',
encryption_key: '<string>',
machine_id: '<string>',
prior_host_id: '<string>',
ssh_address: '<string>'
})
};
fetch('https://custos.example.com/enroll', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://custos.example.com/enroll",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'token' => '<string>',
'public_key' => '<string>',
'hostname' => '<string>',
'encryption_key' => '<string>',
'machine_id' => '<string>',
'prior_host_id' => '<string>',
'ssh_address' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://custos.example.com/enroll"
payload := strings.NewReader("{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://custos.example.com/enroll")
.header("Content-Type", "application/json")
.body("{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://custos.example.com/enroll")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"token\": \"<string>\",\n \"public_key\": \"<string>\",\n \"hostname\": \"<string>\",\n \"encryption_key\": \"<string>\",\n \"machine_id\": \"<string>\",\n \"prior_host_id\": \"<string>\",\n \"ssh_address\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"host_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"signing_public_key": "<string>"
}