Skip to content

Authorized keys

Add or remove SSH public keys for a user.

Manage public keys for an SSH user: add a key, list keys, then remove by name when rotating credentials.

Add an authorized key

Resolve the SSH user (list users if needed), then create with a name and publicKey / public_key.

manageAppSshAuthorizedKeys.jsssh_keys.py
const users = await client.apps.ssh.users.list({ app: "da_XYZ", limit: 1 });
const user = users.data[0];

const key = await client.apps.ssh.users.authorizedKeys.create({
  user: user.id,
  name: "my-laptop",
  publicKey: "ssh-ed25519 AAAA... user@host",
});
// Should return: {
console.log(key.id, key.publicKey);
users = client.apps.ssh.users.list(app="da_XYZ", limit=1)
user = users.data[0]

key = client.apps.ssh.users.authorized_keys.create(
    user=user.id,
    name="my-laptop",
    public_key="ssh-ed25519 AAAA... user@host",
)
# Should return: {
print(key.id, key.public_key)

List keys

List authorized keys for the same user id to confirm the key was stored.

manageAppSshAuthorizedKeys.jsssh_keys.py
const keys = await client.apps.ssh.users.authorizedKeys.list({
  user: user.id,
  limit: 10,
});
console.log(keys.data);
keys = client.apps.ssh.users.authorized_keys.list(user=user.id, limit=10)
print(keys.data)

Remove a key

Delete by user and key name when rotating or revoking access.

manageAppSshAuthorizedKeys.jsssh_keys.py
await client.apps.ssh.users.authorizedKeys.del({ user: user.id, name: "my-laptop" });
console.log("Key removed");
client.apps.ssh.users.authorized_keys.delete(user=user.id, name="my-laptop")
print("Key removed")

Source: stackmachine/sdks examples.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close