Get your free beta license ↗
API operation · users group
POST

/users/{name}/ssh-keys

First published 3 Oct 20260.1.0Unchanged since publication

Add an SSH public key for a customer

Who may call it
AdministratorResellerCustomer
Token scope, any of
usersall
Answers201 Created

Administrators, the customer's reseller and the customer can add a key. The target needs a Linux account. Administrator accounts lack one.

Supply one public key line in ssh-keygen format, with the key type, key data and an optional comment. Omit authorized_keys options. UrbeStack trims surrounding whitespace and returns 400 if key is empty or contains multiple lines. UrbeStack rejects DSA keys and validates public keys with ssh-keygen -l.

A label must contain 1 to 64 printable ASCII characters. If label is omitted or empty, UrbeStack uses up to 64 printable ASCII characters from the key comment, or the key type if the comment yields no label. Each customer can keep up to ssh_keys_max keys, which defaults to 20. A fingerprint already on that customer's list returns 409.

The response contains the added key in key. UrbeStack immediately updates the customer's file under ssh_keys_dir, /etc/urbestack/ssh/keys/<name> by default. sshd reads that file alongside the customer's .ssh/authorized_keys.

As a command

Run as root on the server

Parameters

namepath ·UsernameRequired

Request body

JSON ·SshKeyCreate· 2 fields
keystring, up to 16384 charactersRequired
One public key in the format produced by ssh-keygen. Supply only the key type, key data and optional comment.
labelstring, up to 64 characters
Optional label of 1 to 64 printable characters. If omitted, the label defaults to the key's comment if present, or the key type otherwise.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/users/alice/ssh-keys" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "panel.port",
    "label": "my laptop"
  }'
Response · 201 Created
{
  "key": {
    "created_at": "2026-09-09T10:15:00Z",
    "fingerprint": "text",
    "id": 1,
    "key": "panel.port",
    "label": "my laptop",
    "type": "rebuild",
    "user": "alice"
  }
}

Errors

12 errors, each a status and a sentence
400--key-stdin is required: the key comes on standard input
400--user is required
400<user.name> has <n> SSH keys, the limit: remove one first
400<user.name> is an administrator: administrators have no system account, so no SSH keys here
400Invalid label: 1 to 64 printable ASCII characters
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400Paste one public key, on one line
400Username '<value>' is reserved
400key is required: one public key, as ssh-keygen writes it
401Authentication required
404User '<user>' not found
409This key is on the list already, as '<dup.label>'
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/post-users-name-ssh-keys/