List SSH users on an app, then update authentication settings for one user.
List SSH users
Pass the app ID and an optional limit. Use users.data to pick a user to update.
manageAppSshUsers.jsssh_users.py
const users = await client.apps.ssh.users.list({
app: "da_XYZ",
limit: 10,
});
// Should return: { "data": [ { "id": "ssh_user_abc", "username": "u123", ... } ], "hasMore": false }
console.log(users.data);users = client.apps.ssh.users.list(app="da_XYZ", limit=10)
print(users.data)Update a user
Set authenticationMethods / authentication_methods to PASSWORD, PUBLIC_KEY, or both.
manageAppSshUsers.jsssh_users.py
const user = users.data[0];
const updated = await client.apps.ssh.users.update(user.id, {
authenticationMethods: ["PASSWORD", "PUBLIC_KEY"], // options: "PASSWORD", "PUBLIC_KEY", or both
});
// Should return: {
// "id": "ssh_user_abc",
// "username": "u123",
// "port": 22,
// "serverHost": "ssh.example.com",
// "sftpRootFolder": "/",
// "authenticationMethods": ["PASSWORD", "PUBLIC_KEY"]
// }
console.log(updated.username, updated.serverHost, updated.port);user = users.data[0]
updated = client.apps.ssh.users.update(
user.id,
authentication_methods=["PASSWORD", "PUBLIC_KEY"], # options: "PASSWORD", "PUBLIC_KEY", or both
)
# Should return: {
# "id": "ssh_user_abc",
# "username": "u123",
# "port": 22,
# "server_host": "ssh.example.com",
# "authentication_methods": ["PASSWORD", "PUBLIC_KEY"]
# }
print(updated.username, updated.server_host, updated.port)Source: stackmachine/sdks examples.