vps
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHostinger VPS
Hostinger VPS
The VPS API provides comprehensive management of virtual private servers — from purchasing and setup to Docker deployments, firewall configuration, SSH keys, backups, snapshots, OS reinstallation, recovery mode, malware scanning, and performance monitoring.
VPS API 提供虚拟专用服务器的全面管理功能——从购买、设置到 Docker 部署、防火墙配置、SSH 密钥管理、备份、快照、操作系统重装、恢复模式、恶意软件扫描以及性能监控。
Table of Contents
目录
Core Concepts
核心概念
Virtual Machines
虚拟机
VPS instances with dedicated CPU, RAM, disk, and network resources. Each VM has an OS template, root access, and an IP address. VMs go through states: → → .
initialrunningstopped具备专用CPU、内存、磁盘和网络资源的VPS实例。每个虚拟机都有操作系统模板、root权限和IP地址。虚拟机的状态流程为: → → 。
initialrunningstoppedActions
操作
Asynchronous operations on VMs (start, stop, restart, recreate, etc.) return an action resource with a status you can poll.
对虚拟机执行的异步操作(启动、停止、重启、重建等)会返回一个操作资源,你可以轮询其状态。
Docker Manager
Docker 管理器
Deploy and manage Docker Compose projects directly on VPS instances. Supports creating projects from content or GitHub URLs.
docker-compose.yaml直接在VPS实例上部署和管理Docker Compose项目。支持通过内容或GitHub URL创建项目。
docker-compose.yamlFirewalls
防火墙
Network security rules that control inbound traffic. By default, all incoming traffic is dropped — you must explicitly add accept rules. Only one firewall can be active per VM at a time. Changes require manual sync to take effect.
控制入站流量的网络安全规则。默认情况下,所有入站流量都会被拒绝——你必须明确添加允许规则。每个虚拟机同一时间只能激活一个防火墙。规则变更需要手动同步才能生效。
SSH Public Keys
SSH 公钥
SSH keys for authentication. Keys are managed at the account level and attached to specific VMs.
用于身份验证的SSH密钥。密钥在账户级别管理,并附加到特定虚拟机。
OS Templates
操作系统模板
Pre-configured operating system images for VM installation (Ubuntu, Debian, CentOS, etc.) including panel templates (e.g., with cPanel or Plesk).
用于虚拟机安装的预配置操作系统镜像(Ubuntu、Debian、CentOS等),包括面板模板(如带有cPanel或Plesk的模板)。
Post-Install Scripts
安装后脚本
Automation scripts that run after VM installation. Saved to with executable permissions. Output goes to . Maximum size: 48KB.
/post_install/post_install.log虚拟机安装完成后运行的自动化脚本。脚本会保存到并赋予执行权限,输出内容会写入。最大大小为48KB。
/post_install/post_install.logBackups & Snapshots
备份与快照
- Backups: Automatic periodic backups managed by Hostinger
- Snapshots: User-initiated point-in-time captures. Only one snapshot per VM — creating a new one overwrites the existing one
- 备份:由Hostinger管理的自动定期备份
- 快照:用户触发的时间点捕获。每个虚拟机只能有一个快照——创建新快照会覆盖现有快照
Recovery Mode
恢复模式
Boot the VM from a recovery disk image for system rescue. The original disk is mounted at .
/mnt从恢复磁盘镜像启动虚拟机以进行系统救援。原始磁盘会挂载在目录。
/mntMalware Scanner (Monarx)
恶意软件扫描器(Monarx)
Optional security tool for malware detection and prevention on VPS instances.
用于VPS实例恶意软件检测和防护的可选安全工具。
Common Patterns
常见模式
Purchase and Setup a VPS
购买并设置VPS
bash
undefinedbash
undefinedStep 1: Get available OS templates
Step 1: Get available OS templates
curl -X GET "https://developers.hostinger.com/api/vps/v1/templates"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/templates"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Step 2: Get available data centers
Step 2: Get available data centers
curl -X GET "https://developers.hostinger.com/api/vps/v1/data-centers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/data-centers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Step 3: Purchase a VPS
Step 3: Purchase a VPS
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "item_id": "hostingercom-vps-kvm2-usd-1m", "payment_method_id": 517244, "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
Step 4: Setup purchased VM (if in initial state)
Step 4: Setup purchased VM (if in initial state)
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/setup"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
**CLI (hapi):**
```bash
hapi vps vm listPython SDK:
python
from hostinger_api import Hostinger
client = Hostinger(api_token="YOUR_API_TOKEN")curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/setup"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "data_center_id": 1, "hostname": "my-server", "password": "SecurePass123!" }'
**CLI (hapi):**
```bash
hapi vps vm listPython SDK:
python
from hostinger_api import Hostinger
client = Hostinger(api_token="YOUR_API_TOKEN")List all VPS instances
List all VPS instances
vms = client.vps.virtual_machines.list()
for vm in vms:
print(f"{vm.hostname} - {vm.state} - {vm.ip_address}")
**TypeScript SDK:**
```typescript
import { Hostinger } from "hostinger-api-sdk";
const client = new Hostinger({ apiToken: "YOUR_API_TOKEN" });
const vms = await client.vps.virtualMachines.list();
for (const vm of vms) {
console.log(`${vm.hostname} - ${vm.state} - ${vm.ipAddress}`);
}PHP SDK:
php
use Hostinger\Api\HostingerApi;
$client = new HostingerApi('YOUR_API_TOKEN');
$vms = $client->vps->virtualMachines->list();
foreach ($vms as $vm) {
echo "{$vm->hostname} - {$vm->state} - {$vm->ip_address}\n";
}vms = client.vps.virtual_machines.list()
for vm in vms:
print(f"{vm.hostname} - {vm.state} - {vm.ip_address}")
**TypeScript SDK:**
```typescript
import { Hostinger } from "hostinger-api-sdk";
const client = new Hostinger({ apiToken: "YOUR_API_TOKEN" });
const vms = await client.vps.virtualMachines.list();
for (const vm of vms) {
console.log(`${vm.hostname} - ${vm.state} - ${vm.ipAddress}`);
}PHP SDK:
php
use Hostinger\Api\HostingerApi;
$client = new HostingerApi('YOUR_API_TOKEN');
$vms = $client->vps->virtualMachines->list();
foreach ($vms as $vm) {
echo "{$vm->hostname} - {$vm->state} - {$vm->ip_address}\n";
}VM Lifecycle Operations
虚拟机生命周期操作
bash
undefinedbash
undefinedList all VMs
List all VMs
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Get VM details
Get VM details
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Start VM
Start VM
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/start"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/start"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Stop VM
Stop VM
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/stop"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/stop"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Restart VM
Restart VM
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/restart"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/restart"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Set hostname
Set hostname
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/hostname"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/hostname"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "hostname": "new-hostname.example.com" }'
Set root password
Set root password
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/root-password"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'
curl -X PUT "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/root-password"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "password": "NewSecurePass123!" }'
Recreate VM (DESTRUCTIVE - all data lost)
Recreate VM (DESTRUCTIVE - all data lost)
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/recreate"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
undefinedcurl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/recreate"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "template_id": 1, "password": "SecurePass123!" }'
undefinedDeploy Docker Compose Projects
部署Docker Compose项目
bash
undefinedbash
undefinedList Docker projects on a VM
List Docker projects on a VM
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Deploy from docker-compose.yaml content
Deploy from docker-compose.yaml content
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "content": "version: "3"\nservices:\n web:\n image: nginx:latest\n ports:\n - "80:80"" }'
Deploy from GitHub URL
Deploy from GitHub URL
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "project_name": "my-app", "url": "https://github.com/user/repo" }'
Get project containers and stats
Get project containers and stats
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/containers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/containers"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
View project logs (last 300 entries)
View project logs (last 300 entries)
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/logs"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/docker/my-app/logs"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Start / Stop / Restart / Update / Delete project
Start / Stop / Restart / Update / Delete project
curl -X POST ".../docker/my-app/start" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/stop" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/restart" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/update" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X DELETE ".../docker/my-app/down" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedcurl -X POST ".../docker/my-app/start" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/stop" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/restart" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST ".../docker/my-app/update" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X DELETE ".../docker/my-app/down" -H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedConfigure Firewalls
配置防火墙
bash
undefinedbash
undefinedCreate a firewall
Create a firewall
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "web-server" }'
Add rules (default drops all — add accept rules for ports you need)
Add rules (default drops all — add accept rules for ports you need)
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/rules"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/rules"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "protocol": "tcp", "port": "80", "source": "0.0.0.0/0", "action": "accept" }'
Activate firewall on a VM
Activate firewall on a VM
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/activate/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/activate/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Sync firewall after rule changes
Sync firewall after rule changes
curl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/sync/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedcurl -X POST "https://developers.hostinger.com/api/vps/v1/firewall/1/sync/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedSSH Key Management
SSH密钥管理
bash
undefinedbash
undefinedCreate SSH key
Create SSH key
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "name": "my-laptop", "key": "ssh-ed25519 AAAA... user@host" }'
Attach key to VM
Attach key to VM
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys/attach/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'
curl -X POST "https://developers.hostinger.com/api/vps/v1/public-keys/attach/12345"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Content-Type: application/json"
-d '{ "ids": [1, 2] }'
List keys on a VM
List keys on a VM
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedcurl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/public-keys"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedBackups and Snapshots
备份与快照
bash
undefinedbash
undefinedList backups
List backups
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Restore a backup (DESTRUCTIVE - overwrites all data)
Restore a backup (DESTRUCTIVE - overwrites all data)
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups/99/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/backups/99/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Create a snapshot (overwrites existing snapshot)
Create a snapshot (overwrites existing snapshot)
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Get current snapshot
Get current snapshot
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
Restore from snapshot
Restore from snapshot
curl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedcurl -X POST "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/snapshot/restore"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedMonitor Performance
监控性能
bash
undefinedbash
undefinedGet VM metrics (CPU, memory, disk, network, uptime)
Get VM metrics (CPU, memory, disk, network, uptime)
curl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/metrics?date_from=2025-05-01T00:00:00Z&date_to=2025-06-01T00:00:00Z"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedcurl -X GET "https://developers.hostinger.com/api/vps/v1/virtual-machines/12345/metrics?date_from=2025-05-01T00:00:00Z&date_to=2025-06-01T00:00:00Z"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
-H "Authorization: Bearer $HOSTINGER_API_TOKEN"
undefinedAPI Reference
API参考
Virtual Machines
虚拟机
| Method | Endpoint | Description |
|---|---|---|
| | List all VMs |
| | Purchase new VM |
| | Get VM details |
| | Setup purchased VM |
| | Start VM |
| | Stop VM |
| | Restart VM |
| | Recreate VM (destructive) |
| | Set hostname |
| | Reset hostname |
| | Set root password |
| | Set panel password |
| | Set nameservers |
| | Get metrics |
| | Get attached SSH keys |
| | Get action history |
| | Get action details |
| 方法 | 端点 | 描述 |
|---|---|---|
| | 列出所有虚拟机 |
| | 购买新虚拟机 |
| | 获取虚拟机详情 |
| | 设置已购买的虚拟机 |
| | 启动虚拟机 |
| | 停止虚拟机 |
| | 重启虚拟机 |
| | 重建虚拟机(破坏性操作) |
| | 设置主机名 |
| | 重置主机名 |
| | 设置root密码 |
| | 设置面板密码 |
| | 设置域名服务器 |
| | 获取指标数据 |
| | 获取已附加的SSH密钥 |
| | 获取操作历史 |
| | 获取操作详情 |
Docker Manager (experimental)
Docker管理器(实验性)
| Method | Endpoint | Description |
|---|---|---|
| | List projects |
| | Create project |
| | Get project contents |
| | Get containers with stats |
| | Get project logs (last 300) |
| | Start project |
| | Stop project |
| | Restart project |
| | Update project |
| | Delete project (irreversible) |
| 方法 | 端点 | 描述 |
|---|---|---|
| | 列出项目 |
| | 创建项目 |
| | 获取项目内容 |
| | 获取容器及统计数据 |
| | 获取项目日志(最近300条) |
| | 启动项目 |
| | 停止项目 |
| | 重启项目 |
| | 更新项目 |
| | 删除项目(不可恢复) |
Firewall
防火墙
| Method | Endpoint | Description |
|---|---|---|
| | List firewalls |
| | Create firewall |
| | Get firewall details |
| | Delete firewall |
| | Create rule |
| | Update rule |
| | Delete rule |
| | Activate on VM |
| | Deactivate on VM |
| | Sync rules to VM |
| 方法 | 端点 | 描述 |
|---|---|---|
| | 列出防火墙 |
| | 创建防火墙 |
| | 获取防火墙详情 |
| | 删除防火墙 |
| | 创建规则 |
| | 更新规则 |
| | 删除规则 |
| | 在虚拟机上激活防火墙 |
| | 在虚拟机上停用防火墙 |
| | 将规则同步到虚拟机 |
SSH Keys, Templates, Scripts, Backups, Snapshots, Recovery, PTR, Malware
SSH密钥、模板、脚本、备份、快照、恢复、PTR、恶意软件
| Method | Endpoint | Description |
|---|---|---|
| | Manage SSH keys |
| | Attach keys to VM |
| | List OS templates |
| | Get template details |
| | Manage scripts |
| | List data centers |
| | List backups |
| | Restore backup |
| | Manage snapshot |
| | Restore snapshot |
| | Start/stop recovery mode |
| | Manage PTR records |
| | Manage malware scanner |
| 方法 | 端点 | 描述 |
|---|---|---|
| | 管理SSH密钥 |
| | 将密钥附加到虚拟机 |
| | 列出操作系统模板 |
| | 获取模板详情 |
| | 管理脚本 |
| | 列出数据中心 |
| | 列出备份 |
| | 恢复备份 |
| | 管理快照 |
| | 从快照恢复 |
| | 启动/停止恢复模式 |
| | 管理PTR记录 |
| | 管理恶意软件扫描器 |
Best Practices
最佳实践
Security
安全
- Always attach SSH keys and disable password auth when possible
- Configure firewalls — default drops all traffic, add only needed ports
- Sync firewalls after any rule change — changes don't auto-apply
- Only one firewall per VM — plan rules in a single firewall
- Install Monarx malware scanner on production servers
- Use strong passwords (12+ chars, mixed case, numbers, not leaked)
- 尽可能始终附加SSH密钥并禁用密码认证
- 配置防火墙——默认拒绝所有流量,仅添加所需端口的规则
- 同步防火墙:规则变更后必须手动同步,变更不会自动生效
- 每个虚拟机只能有一个防火墙——将所有规则规划到单个防火墙中
- 在生产服务器上安装Monarx恶意软件扫描器
- 使用强密码(12个字符以上,包含大小写、数字,未泄露过)
Backups & Recovery
备份与恢复
- Take a snapshot before destructive operations (recreate, major changes)
- Remember: creating a new snapshot overwrites the existing one
- Backup restores overwrite all data on the VM
- Use recovery mode for filesystem repair — original disk is at
/mnt
- 在执行破坏性操作(重建、重大变更)之前创建快照
- 注意:创建新快照会覆盖现有快照
- 恢复备份会覆盖虚拟机上的所有数据
- 使用恢复模式修复文件系统——原始磁盘位于
/mnt
Docker
Docker
- Docker Manager endpoints are experimental — expect changes
- GitHub URLs auto-resolve to in master branch
docker-compose.yaml - Deploying a project with an existing name replaces it
- Use logs endpoint for debugging container issues
- Docker管理器端点为实验性——可能会有变更
- GitHub URL会自动解析到master分支中的
docker-compose.yaml - 部署同名项目会替换现有项目
- 使用日志端点排查容器问题
Performance
性能
- Monitor metrics to right-size your VPS plan
- Set custom nameservers only if you know what you're doing — wrong config breaks DNS resolution
- 监控指标以调整VPS套餐规格
- 仅在了解操作影响的情况下设置自定义域名服务器——错误配置会导致DNS解析失败
Post-Install Scripts
安装后脚本
- Maximum script size: 48KB
- Script runs as , output goes to
/post_install/post_install.log - Test scripts on non-production VMs first
- 脚本最大大小为48KB
- 脚本以运行,输出写入
/post_install/post_install.log - 先在非生产虚拟机上测试脚本
Troubleshooting
故障排查
VM Not Starting
虚拟机无法启动
- Check action history for error details
- VM may be in recovery mode — stop recovery first
- Check if VM is in state — run setup first
initial
- 查看操作历史获取错误详情
- 虚拟机可能处于恢复模式——先停止恢复模式
- 检查虚拟机是否处于状态——先执行设置操作
initial
Cannot SSH Into VM
无法通过SSH连接到虚拟机
- Verify SSH key is attached (not just in account)
- Check firewall allows port 22
- Verify firewall is synced after rule changes
- Try root password login to diagnose
- 验证SSH密钥已附加到虚拟机(而不仅仅是在账户中)
- 检查防火墙是否允许22端口
- 验证规则变更后防火墙已同步
- 尝试使用root密码登录以诊断问题
Firewall Rules Not Taking Effect
防火墙规则未生效
- Rules require manual sync after changes:
POST .../firewall/{id}/sync/{vmId} - Only one firewall can be active per VM
- Default policy is DROP — ensure accept rules exist for needed ports
- 规则变更后需要手动同步:
POST .../firewall/{id}/sync/{vmId} - 每个虚拟机只能激活一个防火墙
- 默认策略为拒绝(DROP)——确保为所需端口添加了允许规则
Docker Project Not Starting
Docker项目无法启动
- Check project logs:
GET .../docker/{name}/logs - Verify docker-compose.yaml is valid
- Ensure required ports are not already in use
- Check VM has enough resources (CPU, RAM, disk)
- 查看项目日志:
GET .../docker/{name}/logs - 验证docker-compose.yaml是否有效
- 确保所需端口未被占用
- 检查虚拟机是否有足够资源(CPU、内存、磁盘)
Password Rejected During Recreate
重建时密码被拒绝
- Must be 12+ characters with uppercase, lowercase, and numbers
- Password is checked against leaked password databases
- Try a completely unique, complex password
- 密码必须包含12个以上字符,且包含大写、小写和数字
- 密码会与泄露密码数据库进行比对
- 尝试使用完全唯一的复杂密码
Action Stuck in Progress
操作卡在进行中
- Poll action status:
GET .../actions/{actionId} - Some operations take several minutes (recreate, backup restore)
- If stuck for extended time, contact support
- 轮询操作状态:
GET .../actions/{actionId} - 部分操作需要几分钟时间(重建、恢复备份)
- 如果长时间卡住,请联系支持人员
See Also
另请参阅
The following deep-dive guides are available in this skill directory:
- — SSH-first deployment workflow for Dockerized apps (7-step process, rollback strategy, verification levels)
deployment-workflow.md - — Docker Compose deployment patterns (WordPress, Node+Redis+Postgres, Traefik SSL, lifecycle management)
docker-patterns.md - — Common firewall configurations (web server, database, Docker host, mail server, TypeScript/PHP examples)
firewall-patterns.md - — Infrastructure as Code with the Hostinger Terraform Provider (VPS provisioning, SSH keys, firewalls, complete infra example)
terraform-examples.md
本技能目录中提供了以下深入指南:
- —— 面向Docker化应用的SSH优先部署工作流(7步流程、回滚策略、验证级别)
deployment-workflow.md - —— Docker Compose部署模式(WordPress、Node+Redis+Postgres、Traefik SSL、生命周期管理)
docker-patterns.md - —— 常见防火墙配置(Web服务器、数据库、Docker主机、邮件服务器、TypeScript/PHP示例)
firewall-patterns.md - —— 使用Hostinger Terraform Provider实现基础设施即代码(VPS配置、SSH密钥、防火墙、完整基础设施示例)
terraform-examples.md