Skip to content

SSH keys ​

Users keep their public SSH keys in Anikeen ID, so services can install them on servers.

The user's SSH keys (user token) ​

MethodPathBody
GET/api/v1/ssh-keys–
POST/api/v1/ssh-keyspublic_key (required), name
GET/api/v1/ssh-keys/{id}–
PUT/api/v1/ssh-keys/{id}name and/or public_key
DELETE/api/v1/ssh-keys/{id}–

Scopes: ssh-keys:read to read, ssh-keys to change.

  • public_key must be a valid SSH public key (at most 16384 characters).
  • name is at most 255 characters. Without a name, the key's comment is used (or SSH key).
shell
curl -X POST https://id.anikeen.com/api/v1/ssh-keys \
  -H 'Authorization: Bearer USER_TOKEN' \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  -d '{"name": "Laptop", "public_key": "ssh-ed25519 AAAAC3Nza… ada@laptop"}'
php
$key = $user->sshKeys()->create('ssh-ed25519 AAAAC3Nza… ada@laptop', 'Laptop');
$key->update('Work laptop');
$key->delete();

foreach ($user->sshKeys()->toArray() as $sshKey) {
    echo $sshKey->name;
}

SSH keys of any user (trusted apps) ​

http
GET /api/v1/client/users/{user}/ssh-keys
Authorization: Bearer APP_TOKEN

The app token needs ssh-keys:read or ssh-keys, and the app must be trusted. Newest keys first.

php
$sshKeys = app(\Anikeen\Id\AnikeenId::class)->sshKeysByUserId($anikeenUserId);

foreach ($sshKeys->toArray() as $sshKey) {
    echo $sshKey->name;
}

Anikeen ID developer documentation