SSH Key API
Manage SSH keys for server access programmatically
Overview
The SSH Key API allows you to manage SSH public keys that can be used for authenticating to servers. SSH keys provide a secure way to access servers without using passwords.
GET List SSH Keys
Retrieve a list of SSH keys for the authenticated customer.
Request
{
"cmd": "sshkey.getall",
"resStart": 0,
"resWindow": 50,
"keyword": "search",
"status": "ACTIVE"
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=sshkey.getall&resStart=0&resWindow=50&keyword=search&status=ACTIVE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'sshkey.getall',
'resStart': 0,
'resWindow': 50,
'keyword': 'search',
'status': 'ACTIVE'
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=sshkey.getall&resStart=0&resWindow=50&keyword=search&status=ACTIVE" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET /api/rest/v2.9/sshkey?resStart=0&resWindow=50&keyword=search&status=ACTIVE Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
resStart |
integer | No | Pagination start offset (default: 0) |
resWindow |
integer | No | Number of results per page (default: 50000) |
id |
integer | No | Filter by SSH key ID |
customerid |
integer | No | Filter by customer ID |
name |
string | No | Filter by SSH key name |
status |
string | No | Filter by status (ACTIVE, INACTIVE) |
keyword |
string | No | Search term (searches name, alias, redirect) |
Response
{
"code": "OK",
"message": "SSHKeys Retrieved Successfully",
"matches": 5,
"results": [
{
"id": 123,
"name": "my-ssh-key",
"publickey": "ssh-rsa AAAAB3NzaC1yc2E...",
"customerid": 456,
"status": "ACTIVE",
"datecreated": 1699123456,
"datemodified": 1699123456
}
]
}
GET Get SSH Key
Retrieve a single SSH key by ID.
Request
GET /api/rest/v2.9/sshkey/123
Response
{
"code": "OK",
"message": "SSHKey Retrieved Successfully",
"results": {
"id": 123,
"name": "my-ssh-key",
"publickey": "ssh-rsa AAAAB3NzaC1yc2E...",
"customerid": 456,
"status": "ACTIVE",
"datecreated": 1699123456,
"datemodified": 1699123456
}
}
POST Create SSH Key
Create a new SSH public key.
Request
{
"cmd": "sshkey.create",
"name": "my-ssh-key",
"publickey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...",
"customerid": 456
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'cmd' => 'sshkey.create',
'name' => 'my-ssh-key',
'publickey' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...',
'customerid' => 456
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.post(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
json={
'cmd': 'sshkey.create',
'name': 'my-ssh-key',
'publickey': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...',
'customerid': 456
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X POST "https://api.rackcorp.net/api/rest/v2.9/json.php" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cmd": "sshkey.create",
"name": "my-ssh-key",
"publickey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...",
"customerid": 456
}'
POST /api/rest/v2.9/sshkey
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
{
"name": "my-ssh-key",
"publickey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC...",
"customerid": 456
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | SSH key name (1-64 characters) |
publickey |
string | Yes | SSH public key content (1-4096 characters) |
customerid |
integer | No | Customer ID (defaults to authenticated customer) |
Response
{
"code": "OK",
"message": "SSHKey Created Successfully",
"id": 123
}
PUT Update SSH Key
Update an existing SSH key.
Request
PUT /api/rest/v2.9/sshkey/123
Content-Type: application/json
{
"id": 123,
"name": "updated-key-name",
"publickey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC..."
}
Response
{
"code": "OK",
"message": "SSHKey Updated Successfully"
}
DELETE Delete SSH Key
Delete an SSH key.
Request
DELETE /api/rest/v2.9/sshkey/123
Response
{
"code": "OK",
"message": "SSHKey Deleted Successfully"
}
Error Responses
If an error occurs, the API will return a response with code: "FAULT":
{
"code": "FAULT",
"message": "Error message"
}