color-ssh 0.5.2

A Rust-based SSH client with syntax highlighting.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<p align="center">
  <img src="https://raw.githubusercontent.com/karsyboy/color-ssh/refs/heads/main/.resources/title.svg" />
</p>

<p align="center">
    <a href="https://github.com/karsyboy/color-ssh/releases">
        <img src="https://img.shields.io/github/v/release/karsyboy/color-ssh?include_prereleases&logo=GitHub&label=Github"></a>
    <a href="https://crates.io/crates/color-ssh">
        <img src="https://img.shields.io/crates/v/color-ssh?logo=Rust"></a>
  <br>
    <a href="https://github.com/karsyboy/color-ssh/actions/workflows/release-plz.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/karsyboy/color-ssh/release-plz.yml?logo=githubactions&logoColor=white&label=CI%2FCD"></a>
    <a href="https://github.com/karsyboy/color-ssh/actions/workflows/release.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/karsyboy/color-ssh/release.yml?logo=Rust&label=Release%20Build"></a>
<p>

---

## 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](https://github.com/karsyboy/color-ssh/releases/) for your platform.

### Using Cargo

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

```bash
cargo install color-ssh
```

### From Source

For development or testing the latest changes:

```bash
# 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

```bash
csh --version
```

---

## Usage

### Basic Command Structure

```bash
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

```bash
# 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:

```bash
# 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:

```yaml
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:

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

#### 3. Highlighting Rules

Define regex patterns and their associated colors:

```yaml
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:

```yaml
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):

```yaml
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:

```yaml
- 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](shell-completion/README.md).

---

## Contributing

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

### 1. Fork and Clone

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

### 2. Create a Feature Branch

```bash
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

```bash
# 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

```bash
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**

---

<p align="center">Made with ❀️ by <a href="https://github.com/karsyboy">@karsyboy</a></p>