Authorized keys
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.js
1
const users = await client.apps.ssh.users.list({ app: "da_XYZ", limit: 1 });
2
const user = users.data[0];
3
4
const key = await client.apps.ssh.users.authorizedKeys.create({
5
user: user.id,
6
name: "my-laptop",
7
publicKey: "ssh-ed25519 AAAA... user@host",
8
});
9
// Should return: {// { ... }
15
console.log(key.id, key.publicKey);
List keys
List authorized keys for the same user id to confirm the key was stored.
manageAppSshAuthorizedKeys.js
1
const keys = await client.apps.ssh.users.authorizedKeys.list({
2
user: user.id,
3
limit: 10,
4
});
5
console.log(keys.data);
Remove a key
Delete by user and key name when rotating or revoking access.
manageAppSshAuthorizedKeys.js
1
await client.apps.ssh.users.authorizedKeys.del({ user: user.id, name: "my-laptop" });
2
console.log("Key removed");
Source: stackmachine/sdks examples.