Skip to main content

Expose documentation via SSH - browse docs using familiar Unix commands

Project description

SSH-Docs

Expose documentation via SSH - Browse your documentation using familiar Unix commands over SSH.

Features

  • 🔒 Secure SSH Access - Standard SSH protocol with authentication options
  • 📁 Read-Only Browsing - Safe exploration of documentation files
  • 🛠️ Unix Commands - Familiar commands: ls, cd, cat, grep, find, head, tail
  • ⚙️ Zero Config - Works out of the box with sensible defaults
  • 🎨 Customizable - Optional YAML configuration for advanced setups
  • 🚀 Easy Setup - Single command to start serving docs

Installation

pip install ssh-docs

Quick Start

Serve Documentation (Zero Config)

# Serve current directory
ssh-docs serve

# Serve specific directory
ssh-docs serve ./docs

# Custom port
ssh-docs serve ./docs -p 3000

Then connect:

ssh localhost -p 2222

Basic Commands

Once connected, use familiar Unix commands:

/site$ ls                    # List files
/site$ cd docs              # Change directory
/site$ cat README.md        # View file
/site$ grep "API" -R .      # Search content
/site$ find . -name "*.md"  # Find files
/site$ head -n 20 file.txt  # First 20 lines
/site$ tail -n 10 file.txt  # Last 10 lines
/site$ pwd                  # Current directory
/site$ help                 # Show commands
/site$ exit                 # Close session

Configuration

Initialize Config File

# Create .ssh-docs.yml with defaults
ssh-docs init

# Interactive setup
ssh-docs init --interactive

Configuration File (.ssh-docs.yml)

# Basic settings
site_name: "My Project Documentation"
content_root: "./docs"
port: 2222
host: "0.0.0.0"

# Authentication
auth:
  type: "public"  # Options: public, key, password
  # For key-based auth:
  # authorized_keys: "~/.ssh/authorized_keys"
  # For password auth:
  # password: "${SSH_DOCS_PASSWORD}"

# Server settings
server:
  banner: |
    Welcome to {site_name} Documentation
    Type 'help' for available commands
  max_connections: 10
  timeout: 300
  log_level: "info"

# Ignore patterns
ignore:
  - "*.pyc"
  - "__pycache__"
  - ".git"
  - "node_modules"

Authentication

Public Access (Default)

No authentication required - anyone can connect:

ssh-docs serve ./docs

Password Authentication

ssh-docs serve ./docs --auth password --password secret123

Or use environment variable:

export SSH_DOCS_PASSWORD="secret123"
ssh-docs serve ./docs --auth password

Key-Based Authentication

ssh-docs serve ./docs --auth key --keys-file ~/.ssh/authorized_keys

Advanced Usage

Generate Host Keys

# Generate keys in default location
ssh-docs keygen

# Custom location
ssh-docs keygen --output-dir ./keys

Validate Configuration

# Validate default config
ssh-docs validate

# Validate specific config
ssh-docs validate custom-config.yml

Using Config File

# Use default .ssh-docs.yml
ssh-docs serve

# Use custom config
ssh-docs serve --config production.yml

# Ignore config file
ssh-docs serve --no-config

CLI Reference

ssh-docs serve

Start SSH documentation server.

Options:

  • CONTENT_DIR - Directory to serve (default: auto-detect)
  • -p, --port - Port to listen on (default: 2222)
  • -n, --site-name - Site name for banner (default: auto-detect)
  • -c, --config - Config file path (default: .ssh-docs.yml)
  • --host - Host to bind to (default: 0.0.0.0)
  • --auth - Auth type: public, key, password (default: public)
  • --keys-file - Authorized keys file (for key auth)
  • --password - Password (for password auth)
  • --no-config - Ignore config file
  • --log-level - Log level: debug, info, warn, error

Examples:

# Basic usage
ssh-docs serve ./docs

# Custom port and name
ssh-docs serve ./docs -p 3000 -n "My API Docs"

# Password auth
ssh-docs serve --auth password --password secret123

# Use config file
ssh-docs serve --config production.yml

ssh-docs init

Initialize configuration file.

Options:

  • --interactive - Interactive setup wizard
  • --template - Template: basic, advanced

Examples:

# Create basic config
ssh-docs init

# Interactive setup
ssh-docs init --interactive

ssh-docs validate

Validate configuration file.

Examples:

# Validate default config
ssh-docs validate

# Validate specific config
ssh-docs validate custom-config.yml

ssh-docs keygen

Generate SSH host keys.

Options:

  • --output-dir - Where to save keys (default: ~/.ssh-docs/keys)
  • --force - Overwrite existing keys

Examples:

# Generate in default location
ssh-docs keygen

# Custom location
ssh-docs keygen --output-dir ./keys

Use Cases

Local Development

# Serve docs while developing
cd my-project
ssh-docs serve ./docs

CI/CD Integration

# In Dockerfile or CI script
pip install ssh-docs
ssh-docs serve /app/docs --port 2222 &

Production Deployment

# docker-compose.yml
services:
  docs:
    image: python:3.11
    command: sh -c "pip install ssh-docs && ssh-docs serve /docs"
    ports:
      - "2222:2222"
    volumes:
      - ./docs:/docs:ro

Documentation Server

# Production setup with auth
ssh-docs init --interactive
ssh-docs keygen
ssh-docs serve --auth key --keys-file ~/.ssh/authorized_keys

Security Considerations

  • Read-Only: All operations are read-only by default
  • Path Traversal Protection: Prevents access outside content root
  • Authentication: Supports password and key-based auth
  • Connection Limits: Configurable max connections
  • Timeouts: Automatic session timeouts

Auto-Detection

SSH-Docs automatically detects:

  • Content Directory: Looks for docs/, documentation/, public/, dist/
  • Site Name: Reads from package.json, pyproject.toml, or directory name
  • Host Keys: Generates if not present

Requirements

  • Python 3.8+
  • asyncssh
  • click
  • pyyaml (optional, for config files)

Development

# Clone repository
git clone https://github.com/ssh-docs/ssh-docs.git
cd ssh-docs

# Install in development mode
pip install -e .

# Run tests
pytest

# Run locally
python -m ssh_docs serve ./demo-website

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please open an issue or submit a pull request.

Support

Roadmap

  • Syntax highlighting for code files
  • Search index for faster grep
  • Custom command plugins
  • Docker image
  • NPM package wrapper
  • Web-based terminal viewer
  • Session recording/replay
  • Multi-user support with permissions

Made with ❤️ for developers who love the terminal

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssh_docs-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssh_docs-0.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file ssh_docs-0.1.0.tar.gz.

File metadata

  • Download URL: ssh_docs-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for ssh_docs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1554ddbf51b73763eef06d2dd85bcee352df848150e11c83c8ab0d2f1ecafb44
MD5 c84d17914dea6158b5a05dba896ed3ce
BLAKE2b-256 f44b1d349d7447934e9f7b8f5a3f8d54c36b508d22504086dbbce07994df06fb

See more details on using hashes here.

File details

Details for the file ssh_docs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ssh_docs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for ssh_docs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1f4f24142e4dc6150597fcc6a837bc645d2f04a611127f71417712142a3a274
MD5 0cd516c8c6560ba635e1436096b83f8a
BLAKE2b-256 e4da711ec0b0f82d9b33e9d51278dff5cfdf16d9bbc02321aee0119f4f82bae0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page