home / skills / artwist-polyakov / polyakov-claude-skills / ssh-remote-connection

This skill enables secure remote management by executing SSH commands, viewing logs, and restarting services on a server.

npx playbooks add skill artwist-polyakov/polyakov-claude-skills --skill ssh-remote-connection

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.6 KB
---
name: ssh-remote-connection
description: SSH connection to remote servers. Use when you need to execute commands on a remote server, check logs, restart services, or manage Docker containers.
---

# SSH Remote Connection

Universal skill for connecting to remote servers via SSH.

## Usage

```bash
# Interactive shell
scripts/connect.sh

# Run command directly
scripts/connect.sh "docker compose logs backend --tail 50"
```

## Setup

### For Claude Code (local)

1. Copy config template:
   ```bash
   cp config/.env.example config/.env
   ```

2. Fill in `config/.env` with actual values

3. Make script executable:
   ```bash
   chmod +x scripts/connect.sh
   ```

### For Cloud Runtime

Set environment variables in your cloud configuration:
- `SSH_HOST` — server hostname or IP
- `SSH_USER` — SSH username
- `SSH_KEY_PATH` — path to private key
- `SSH_KEY_PASSWORD` — key passphrase (optional)
- `SERVER_PROJECT_PATH` — project directory on server

## Important Notes

- **Git operations**: Do NOT run `git pull` on the server. User will handle git sync manually.
- **Code location**: Code is in a private repo, changes must be pushed first then pulled by user.
- **Docker**: Use `docker compose` (not `docker-compose`) on the server.

## Example Commands

```bash
# View logs
scripts/connect.sh "docker compose logs backend --tail 100"

# Restart service
scripts/connect.sh "docker compose restart backend"

# Rebuild and restart
scripts/connect.sh "docker compose build backend && docker compose up -d backend"

# Check status
scripts/connect.sh "docker compose ps"
```

Overview

This skill provides a lightweight SSH connection tool to run commands on remote servers, inspect logs, restart services, and manage Docker containers. It wraps SSH access into a simple script usable interactively or for single-command execution. Configuration is managed via environment variables or a local .env file.

How this skill works

The skill uses an SSH wrapper script to connect to the target host with provided SSH user and key information. It can open an interactive shell or execute a single remote command (for example, Docker Compose operations) and returns the command output. Environment variables control host, user, key path, key passphrase, and the server project path so the same script works locally or in cloud runtimes.

When to use it

  • Execute maintenance commands on a remote server without opening a manual SSH session
  • View service logs or tail recent output from containers
  • Restart or rebuild specific Docker Compose services remotely
  • Run status checks for Docker Compose-managed projects
  • Perform quick ad-hoc checks or scripted one-liners on the server

Best practices

  • Store connection values in a .env file or secure cloud environment variables, not in code
  • Make the connect script executable (chmod +x) and verify SSH key permissions
  • Avoid running git pull remotely—synchronize code via push/pull workflows outside this tool
  • Prefer docker compose (modern CLI) rather than legacy docker-compose on the server
  • Use single-command mode for non-interactive tasks to capture output reliably

Example use cases

  • Open an interactive shell on the production host to inspect running processes or logs
  • Fetch the last 100 lines of backend logs: scripts/connect.sh "docker compose logs backend --tail 100"
  • Restart the backend service remotely: scripts/connect.sh "docker compose restart backend"
  • Rebuild and redeploy a service without full server access: scripts/connect.sh "docker compose build backend && docker compose up -d backend"
  • Check container status: scripts/connect.sh "docker compose ps"

FAQ

How do I configure the connection details?

Copy the example .env to config/.env and fill in SSH_HOST, SSH_USER, SSH_KEY_PATH, optional SSH_KEY_PASSWORD, and SERVER_PROJECT_PATH; or set equivalent cloud environment variables.

Can I run git pull through this script?

No. Do not run git pull on the server with this tool. Push changes from your local environment and have the server user handle repository sync manually.