Add an SSH key
curl --request POST \
--url {schemes}://api.upsun.com/users/{user_id}/ssh-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com",
"label": "<string>"
}
'import requests
url = "{schemes}://api.upsun.com/users/{user_id}/ssh-keys"
payload = {
"value": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com",
"label": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
value: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com',
label: '<string>'
})
};
fetch('{schemes}://api.upsun.com/users/{user_id}/ssh-keys', 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 => "{schemes}://api.upsun.com/users/{user_id}/ssh-keys",
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([
'value' => 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com',
'label' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "{schemes}://api.upsun.com/users/{user_id}/ssh-keys"
payload := strings.NewReader("{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("{schemes}://api.upsun.com/users/{user_id}/ssh-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/users/{user_id}/ssh-keys")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"sha256": "<string>",
"value": "<string>",
"label": "<string>",
"active": true,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "insufficient_user_authentication",
"error_description": "More recent authentication is required."
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}SSH
Add an SSH key
Registers an SSH public key for the specified user. Requires a recent authentication.
POST
/
users
/
{user_id}
/
ssh-keys
Add an SSH key
curl --request POST \
--url {schemes}://api.upsun.com/users/{user_id}/ssh-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com",
"label": "<string>"
}
'import requests
url = "{schemes}://api.upsun.com/users/{user_id}/ssh-keys"
payload = {
"value": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com",
"label": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
value: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com',
label: '<string>'
})
};
fetch('{schemes}://api.upsun.com/users/{user_id}/ssh-keys', 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 => "{schemes}://api.upsun.com/users/{user_id}/ssh-keys",
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([
'value' => 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com',
'label' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "{schemes}://api.upsun.com/users/{user_id}/ssh-keys"
payload := strings.NewReader("{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("{schemes}://api.upsun.com/users/{user_id}/ssh-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{schemes}://api.upsun.com/users/{user_id}/ssh-keys")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@example.com\",\n \"label\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"sha256": "<string>",
"value": "<string>",
"label": "<string>",
"active": true,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "insufficient_user_authentication",
"error_description": "More recent authentication is required."
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the user.
Example:
"d81c8ee2-44b3-429f-b944-a33ad7437690"
Body
application/json
Response
Created
The ID of the SSH key.
The SHA-256 fingerprint of the public key.
The SSH public key in the OpenSSH authorized keys format.
A human-readable name for the key.
Whether the key can be used for authentication.
The ID of the user who owns the key.
The date and time when the key was added.
The date and time when the key was last updated.
Was this page helpful?