Skip to main content
SSH key methods manage the public keys associated with your Phala Cloud account. These keys are injected into CVMs at boot time, giving you SSH access to your running instances.

list_ssh_keys

GET /user/ssh-keys Lists all SSH keys registered to your account. Parameters: None. Returns: List of SSH key objects. Example:

create_ssh_key

POST /user/ssh-keys Adds a new SSH public key to your account. Parameters: Returns: The created SSH key object. Example: Replace the sample public key with your own key before using it for access.

delete_ssh_key

DELETE /user/ssh-keys/{keyId} Removes an SSH key from your account. Existing CVMs that were provisioned with this key will retain it until they are restarted. Parameters: Returns: None Example:

import_github_profile_ssh_keys

POST /user/ssh-keys/github-profile Imports SSH public keys from a GitHub user profile. This fetches the keys listed at https://github.com/{username}.keys and adds them to your account. Parameters: Returns: Import response with the number of keys imported. Example:

sync_github_ssh_keys

POST /user/ssh-keys/github-sync Syncs SSH keys from your connected GitHub account. This requires that your Phala Cloud account is linked to GitHub via OAuth. Unlike import_github_profile_ssh_keys, this uses your authenticated GitHub connection and keeps keys in sync. Parameters: None. Returns: Sync response with details of added/removed keys. Example:

CVM SSH keys

get_cvm_ssh_keys({"cvm_id": "my-app"}) reads GET /cvms/{cvmId}/ssh-keys. It returns a CvmSshKeysResponse with keys and restart_required. This is the stored configuration; use get_cvm_user_config for the running VM’s configuration. update_cvm_ssh_keys sends PUT /cvms/{cvmId}/ssh-keys and replaces the configured key set. ssh_key_ids is required: include every selected key you want to retain. An empty list removes all selected keys unless usernames adds members’ resolved keys. Changes take effect at the next power-on, or immediately if apply_now restarts the CVM. This example uses the key created above. Add any other key IDs you want to retain.
The async client supports the same calls with await. Both methods also have safe_ variants.