from gravixlayer import GravixLayer
from pathlib import Path
import os
client = GravixLayer()
runtime = client.runtime.create(template="python-3.12-base-small")
ssh = client.runtime.enable_ssh(runtime.runtime_id)
print(ssh.enabled) # True
print(ssh.username) # e.g. "user"
print(ssh.port) # e.g. 22
print(ssh.connect_cmd) # Full ssh command
# Save the private key locally
if ssh.private_key:
key_path = Path.home() / f".gravixlayer-{runtime.runtime_id}.pem"
key_path.write_text(ssh.private_key, encoding="utf-8")
os.chmod(key_path, 0o600)
client.runtime.kill(runtime.runtime_id)
Parameters
| Parameter | Type | Required | Description |
|---|
runtime_id | string | Yes | Runtime identifier |
regenerate_keys | boolean | No | Regenerate SSH keys (default False) |
Response
| Field | Type | Description |
|---|
runtime_id | string | Runtime identifier |
enabled | boolean | SSH enabled status |
port | integer | SSH port |
username | string | SSH username |
connect_cmd | string | Full SSH command |
private_key | string | PEM-encoded private key |
public_key | string | Public key |
ssh_config | string | SSH config block |
message | string | Status message |
Store private keys securely and set file permissions to 600.