color-ssh 0.5.0

A Rust-based SSH client with syntax highlighting.
Documentation

About

Color SSH (csh) is a powerful Rust-based wrapper for SSH that enhances your terminal experience with real-time syntax highlighting and intelligent logging. Built for network engineers, system administrators, and anyone who works extensively with SSH, csh transforms plain SSH output into beautifully highlighted text using customizable, regex-based rules.

Whether you're managing network devices, debugging servers, or analyzing logs, Color SSH makes it easier to spot critical information at a glance. Errors will stand out in red, successful operations will glow green, and everything is configurable to match your workflow.


Features

  • 🎨 Real-time Syntax Highlighting: Apply regex-based color rules to SSH output as it streams
  • βš™οΈ Highly Configurable: YAML-based configuration with custom color palettes and regex rules
  • πŸ“ Session Logging: Automatic logging of SSH sessions with organized date-based storage
  • πŸ”’ Secret Redaction: Automatically remove sensitive data (passwords, keys, hashes) from logs
  • πŸ“‹ Profile Support: Multiple configuration profiles for different environments (network devices, servers, etc.)
  • 🎯 Template Library: Pre-built templates for network equipment and common use cases β€” community contributions welcome!
  • πŸ”„ Hot Reload: Configuration changes apply automatically without restarting
  • 🐚 Shell Integration: Enhanced tab completion and interactive host selection for Fish and Zsh
  • πŸš€ Drop-in Replacement: Works seamlessly as an SSH wrapperβ€”just use csh instead of ssh

Installation

Using Pre-built Binaries (Recommended)

Download the latest release from GitHub Releases for your platform.

Using Cargo

If you have Rust installed, install directly from crates.io:

cargo install color-ssh

From Source

For development or testing the latest changes:

# Clone the repository
git clone https://github.com/karsyboy/color-ssh.git
cd color-ssh

# Build the release binary
cargo build --release

# Optional: Install to system path
sudo cp target/release/csh /usr/local/bin/

Verify Installation

csh --version

Usage

Basic Command Structure

csh [OPTIONS] <ssh_args>...

Options

Option Description
-d, --debug Enable debug mode with detailed logging to ~/.csh/logs/csh.log
-l, --log Enable SSH session logging to ~/.csh/logs/ssh_sessions/
-P, --profile <name> Use a specific configuration profile
-h, --help Display help information
-V, --version Display version information

Examples

# Basic SSH connection with syntax highlighting
csh user@hostname

# Enable session logging
csh -l admin@router.example.com

# Use a specific configuration profile
csh -P network cisco@switch.local

# Debug mode for troubleshooting
csh -d user@server.com

# Combine options (logging + profile)
csh -l -P network user@firewall.example.com

# Pass SSH arguments through
csh -l user@host -p 2222 -i ~/.ssh/custom_key

# Non-interactive SSH commands (highlighting disabled automatically)
csh user@host -G          # Dump SSH configuration
csh user@host -T          # Disable pseudo-terminal

Session Logs

When using the -l or --log flag, SSH sessions are logged to:

~/.csh/logs/ssh_sessions/YYYY-MM-DD/HOSTNAME.log

Example:

~/.csh/logs/ssh_sessions/2026-01-26/router1.log

Configuration

Configuration File Locations

Color SSH looks for configuration files in the following order:

  1. Current directory: ./[profile].csh-config.yaml
  2. Home directory: ~/.csh/[profile].csh-config.yaml

If no configuration file exists, Color SSH will automatically create a default configuration at ~/.csh/.csh-config.yaml.

Configuration Profiles

Use profiles to maintain different configurations for different environments:

# Default profile
~/.csh/.csh-config.yaml

# Network devices profile
~/.csh/network.csh-config.yaml

# Usage
csh -P network user@switch.local

Configuration Structure

A configuration file consists of three main sections:

1. Settings

Optional settings for controlling Color SSH behavior:

settings:
  show_title: true              # Display a colored title banner
  debug_mode: false             # Enable debug logging
  ssh_logging: true             # Enable session logging by default
  remove_secrets:               # Regex patterns to redact from logs
    - '9[\s]\$9\$.*'           # Juniper type 9 secrets
    - 'sha512[\s]\$6\$.*'      # SHA-512 hashes
    - 'ssh-ed25519[\s].*'      # SSH public keys

2. Color Palette

Define reusable colors using hex codes:

palette:
  Red: '#c71800'
  Green: '#28c501'
  Blue: '#5698c8'
  Orange: '#e67547'
  Gold: '#a35a00'

3. Highlighting Rules

Define regex patterns and their associated colors:

rules:
  - description: Highlight successful operations
    regex: (?ix)\b(success|ok|connected|up|enabled)\b
    color: Green

  - description: Highlight errors and failures
    regex: (?ix)\b(error|fail|down|disabled|denied)\b
    color: Red

  - description: Highlight IP addresses
    regex: \b(?:\d{1,3}\.){3}\d{1,3}\b
    color: Blue

Example: Default Configuration

The default configuration template (templates/default.csh-config.yaml) provides basic keyword highlighting:

palette:
  Red: '#c71800'
  Green: '#28c501'
  Blue: '#5698c8'

rules:
  - description: Match on good keywords
    regex: (?ix)\b(good|up|success|ok|connected)\b
    color: Green

  - description: Match on neutral keywords
    regex: (?ix)\b(neutral|info|status)\b
    color: Blue

  - description: Match on bad keywords
    regex: (?ix)\b(down|error|disabled|fail|denied)\b
    color: Red

Example: Network Devices Configuration

For network engineers, the templates/network.csh-config.yaml template provides extensive highlighting for Cisco and other network devices (Reference the actual file for a detailed config):

settings:
  remove_secrets:
    - '9[\s]\$9\$.*'           # Juniper secrets
    - 'sha512[\s]\$6\$.*'      # Password hashes
    - '7[\s][0-9]{2}[0-9A-Fa-f]+$'  # Cisco type 7
  show_title: true
  ssh_logging: true

palette:
  Orange: '#e67547'
  Aqua: '#00e0d1'
  Gold: '#a35a00'
  Green: '#28c501'
  Red: '#c71800'

rules:
  - description: Cisco enable mode prompt
    regex: (\S+)#
    color: Orange

  - description: Cisco user mode prompt
    regex: (\S+)>
    color: Gold

  - description: Interface names
    regex: (?ix)\b(GigabitEthernet|FastEthernet|Vlan|Port-channel)\d+(/\d+)*(\.\d+)?\b
    color: Green

Regex Tips

Color SSH uses Rust's regex crate with support for:

  • Case-insensitive matching: Use (?i) flag
  • Extended mode (ignore whitespace): Use (?x) flag
  • Multi-line patterns: Use | for multi-line regex blocks in YAML
  • Word boundaries: Use \b to match whole words
  • Groups: Use () for capturing groups

Example of a well-structured rule:

- description: Match Cisco interface types
  regex: |
    (?ix)                          # Case-insensitive, extended mode
    \b                             # Word boundary
    (gigabitethernet|gi|
     tengigabitethernet|te|
     fastethernet|fa)
    \d+(/\d+)*(\.\d+)?            # Port numbers
    \b                             # Word boundary
  color: Green

Shell Completion

Color SSH includes advanced shell completion features for Fish and Zsh shells, including:

  • Tab completion for SSH hosts from your ~/.ssh/config
  • Interactive host selection with fuzzy finding (fzf)
  • Host descriptions and previews
  • Support for SSH config Include directives

For detailed installation and usage instructions, see the Shell Completion README.


Contributing

Contributions are welcomed! Here's how to get started:

1. Fork and Clone

git clone https://github.com/YOUR-USERNAME/color-ssh.git
cd color-ssh

2. Create a Feature Branch

git checkout -b feature/your-feature-name

3. Make Your Changes

  • Write clean, idiomatic Rust code
  • Add tests for new functionality
  • Update documentation as needed
  • Follow existing code style and conventions

4. Test Your Changes

# Run tests
cargo test

# Build and test locally
cargo build --release
./target/release/csh user@testhost

# Run linter
cargo clippy

# Format code
cargo fmt

5. Commit and Push

git add .
git commit -m "feat: add your feature description"
git push origin feature/your-feature-name

6. Open a Pull Request

  • Provide a clear description of your changes
  • Reference any related issues
  • Ensure CI/CD checks pass

Contribution Ideas

  • 🎨 New configuration templates for specific platforms
  • πŸ› Bug fixes and performance improvements
  • πŸ“š Documentation enhancements
  • ✨ New features β€” check the roadmap or propose your own ideas
  • πŸ§ͺ Additional test coverage

Code of Conduct

Please be respectful and constructive. We're building this together!


License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2025 Karsyboy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Roadmap

  • πŸ”„ Coming Soon