Skip to main content
SSH key methods manage the public keys authorized for SSH access to your CVMs. You can add keys manually, import them from a GitHub profile, or sync them from your linked GitHub account.

ListSSHKeys

GET /user/ssh-keys Returns all SSH keys registered for the current user.
func (c *Client) ListSSHKeys(ctx context.Context) ([]SSHKey, error)
Returns: []SSHKey where each SSHKey contains:
FieldTypeDescription
IDstringKey identifier
NamestringDisplay name
PublicKeystringPublic key content
Fingerprint*stringKey fingerprint
KeyType*stringKey type (e.g., "ssh-ed25519")
Source*stringHow the key was added (e.g., "manual", "github")
CreatedAt*stringCreation timestamp
keys, err := client.ListSSHKeys(ctx)
if err != nil {
	log.Fatal(err)
}
for _, key := range keys {
	fmt.Printf("%s%s (%s)\n", key.Name, key.ID, *key.KeyType)
}

CreateSSHKey

POST /user/ssh-keys Registers a new SSH public key.
func (c *Client) CreateSSHKey(ctx context.Context, req *CreateSSHKeyRequest) (*SSHKey, error)
CreateSSHKeyRequest fields:
FieldTypeRequiredDescription
NamestringYesDisplay name for the key
PublicKeystringYesSSH public key content
Returns: *SSHKey — the created key with its assigned ID and fingerprint.
key, err := client.CreateSSHKey(ctx, &phala.CreateSSHKeyRequest{
	Name:      "my-laptop",
	PublicKey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample...",
})
if err != nil {
	log.Fatal(err)
}
fmt.Printf("Created key: %s (fingerprint: %s)\n", key.ID, *key.Fingerprint)

DeleteSSHKey

DELETE /user/ssh-keys/{keyId} Removes an SSH key by its ID. Existing CVMs that were deployed with this key will retain access until they are restarted or updated.
func (c *Client) DeleteSSHKey(ctx context.Context, keyID string) error
Parameters:
FieldTypeRequiredDescription
keyIDstringYesSSH key identifier
Returns: error (no response body on success)
err := client.DeleteSSHKey(ctx, "key-abc123")
if err != nil {
	log.Fatal(err)
}

ImportGithubProfileSSHKeys

POST /user/ssh-keys/github-profile Imports SSH public keys from any GitHub user’s profile. This fetches the keys from https://github.com/{username}.keys and adds them to your account.
func (c *Client) ImportGithubProfileSSHKeys(ctx context.Context, username string) (*ImportGithubResponse, error)
Parameters:
FieldTypeRequiredDescription
usernamestringYesGitHub username
Returns: *ImportGithubResponse (generic map with import details)
imported, err := client.ImportGithubProfileSSHKeys(ctx, "octocat")
if err != nil {
	log.Fatal(err)
}
This imports keys from any public GitHub profile. Use SyncGithubSSHKeys instead if you want to sync keys from your own linked GitHub account.

SyncGithubSSHKeys

POST /user/ssh-keys/github-sync Syncs SSH keys from the user’s linked GitHub account. This requires that the user has connected their GitHub account to Phala Cloud.
func (c *Client) SyncGithubSSHKeys(ctx context.Context) (*SyncGithubResponse, error)
Returns: *SyncGithubResponse (generic map with sync details)
synced, err := client.SyncGithubSSHKeys(ctx)
if err != nil {
	log.Fatal(err)
}