[PR #10251] feat: Add SSH VPS Management for Remote Server Operations #13375

Closed
opened 2026-02-16 18:18:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10251

State: closed
Merged: No


Summary

This PR adds comprehensive SSH VPS (Virtual Private Server) management capabilities to OpenCode, enabling seamless remote server operations directly from the CLI and AI agent.

Features

  • SSH Connection Management: Connect to multiple VPS instances with support for key-based, password, and SSH agent authentication
  • SFTP File Operations: Read, write, list, stat, glob, and grep files on remote servers
  • Interactive PTY Sessions: Full terminal sessions over SSH for interactive commands
  • Context Switching: Switch between local and remote environments seamlessly
  • AI Agent Integration: New vps-exec tool allows the AI to execute commands and manage files on remote servers
  • CLI Commands: Full suite of VPS management commands (vps list, vps connect, vps disconnect, vps status, vps switch)
  • REST API Routes: Server endpoints for VPS management via HTTP

New Files

  • packages/opencode/src/vps/ - Core VPS module
    • index.ts - Module exports
    • connection.ts - SSH connection manager using ssh2
    • auth.ts - Authentication helpers
    • context.ts - Context switching between local/VPS
    • sftp.ts - Remote file operations
    • pty.ts - Interactive terminal sessions
  • packages/opencode/src/server/routes/vps.ts - REST API routes
  • packages/opencode/src/cli/cmd/vps.ts - CLI commands
  • packages/opencode/src/tool/vps-exec.ts - AI agent tool
  • docs/VPS.md - Documentation

Modified Files

  • packages/opencode/package.json - Added ssh2 dependencies
  • packages/opencode/src/config/config.ts - VPS configuration schema
  • packages/opencode/src/id/id.ts - Added VPS identifier prefixes
  • packages/opencode/src/index.ts - Registered VpsCommand
  • packages/opencode/src/server/server.ts - Added VpsRoutes
  • packages/opencode/src/cli/ui.ts - Added color helpers
  • packages/opencode/src/skill/skill.ts - Enhanced with triggers and autoInvoke
  • packages/opencode/src/tool/registry.ts - Registered VpsExecTool

Configuration Example

{
  "vps": {
    "production": {
      "host": "example.com",
      "port": 22,
      "user": "ubuntu",
      "auth": { "type": "key", "keyPath": "~/.ssh/id_rsa" },
      "nickname": "Production Server"
    }
  }
}

Usage

# List configured VPS
opencode vps list

# Connect to a VPS
opencode vps connect production

# Check status
opencode vps status

# Switch context to VPS
opencode vps switch production

# Switch back to local
opencode vps switch local

# Disconnect
opencode vps disconnect production

Testing

  • TypeScript type checking passes
  • Unit tests (to be added)
  • Integration tests with real SSH server

Related

This feature enables users to manage remote servers directly from OpenCode, making it easier to deploy, debug, and maintain applications on VPS instances.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10251 **State:** closed **Merged:** No --- ## Summary This PR adds comprehensive SSH VPS (Virtual Private Server) management capabilities to OpenCode, enabling seamless remote server operations directly from the CLI and AI agent. ## Features - **SSH Connection Management**: Connect to multiple VPS instances with support for key-based, password, and SSH agent authentication - **SFTP File Operations**: Read, write, list, stat, glob, and grep files on remote servers - **Interactive PTY Sessions**: Full terminal sessions over SSH for interactive commands - **Context Switching**: Switch between local and remote environments seamlessly - **AI Agent Integration**: New `vps-exec` tool allows the AI to execute commands and manage files on remote servers - **CLI Commands**: Full suite of VPS management commands (`vps list`, `vps connect`, `vps disconnect`, `vps status`, `vps switch`) - **REST API Routes**: Server endpoints for VPS management via HTTP ## New Files - `packages/opencode/src/vps/` - Core VPS module - `index.ts` - Module exports - `connection.ts` - SSH connection manager using ssh2 - `auth.ts` - Authentication helpers - `context.ts` - Context switching between local/VPS - `sftp.ts` - Remote file operations - `pty.ts` - Interactive terminal sessions - `packages/opencode/src/server/routes/vps.ts` - REST API routes - `packages/opencode/src/cli/cmd/vps.ts` - CLI commands - `packages/opencode/src/tool/vps-exec.ts` - AI agent tool - `docs/VPS.md` - Documentation ## Modified Files - `packages/opencode/package.json` - Added ssh2 dependencies - `packages/opencode/src/config/config.ts` - VPS configuration schema - `packages/opencode/src/id/id.ts` - Added VPS identifier prefixes - `packages/opencode/src/index.ts` - Registered VpsCommand - `packages/opencode/src/server/server.ts` - Added VpsRoutes - `packages/opencode/src/cli/ui.ts` - Added color helpers - `packages/opencode/src/skill/skill.ts` - Enhanced with triggers and autoInvoke - `packages/opencode/src/tool/registry.ts` - Registered VpsExecTool ## Configuration Example ```json { "vps": { "production": { "host": "example.com", "port": 22, "user": "ubuntu", "auth": { "type": "key", "keyPath": "~/.ssh/id_rsa" }, "nickname": "Production Server" } } } ``` ## Usage ```bash # List configured VPS opencode vps list # Connect to a VPS opencode vps connect production # Check status opencode vps status # Switch context to VPS opencode vps switch production # Switch back to local opencode vps switch local # Disconnect opencode vps disconnect production ``` ## Testing - [x] TypeScript type checking passes - [ ] Unit tests (to be added) - [ ] Integration tests with real SSH server ## Related This feature enables users to manage remote servers directly from OpenCode, making it easier to deploy, debug, and maintain applications on VPS instances.
yindo added the pull-request label 2026-02-16 18:18:14 -05:00
yindo closed this issue 2026-02-16 18:18:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13375