color-ssh 0.5.3

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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<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** (`colorsh`) 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, `colorsh` 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 `colorsh` 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/colorsh /usr/local/bin/
```

### Verify Installation

```bash
colorsh --version
```

---

## Uninstall

### Using Cargo

If you installed using cargo:

```bash
cargo uninstall color-ssh
```

Note: This only removes the binary. To completely remove configuration files and logs, also run:

```bash
rm -rf ~/.colorsh/
```

### Using Homebrew

If you installed using Homebrew:

```bash
brew uninstall color-ssh
```

### Linux/macOS (Manual)

If you installed using the installer script, follow these steps:

```bash
# 1. Remove the main binary
rm ~/.cargo/bin/colorsh

# 2. Remove the updater binary (if installed)
rm -f ~/.cargo/bin/color-ssh-update

# 3. Remove configuration and logs
rm -rf ~/.colorsh/

# 4. Remove the installation receipt
rm -rf ~/.config/color-ssh/
```

### Windows

If you installed using the PowerShell installer script:

```powershell
# 1. Remove the main binary
Remove-Item "$env:USERPROFILE\.cargo\bin\colorsh.exe" -Force

# 2. Remove the updater binary (if installed)
Remove-Item "$env:USERPROFILE\.cargo\bin\color-ssh-update.exe" -Force -ErrorAction SilentlyContinue

# 3. Remove configuration and logs
Remove-Item "$env:USERPROFILE\.colorsh" -Recurse -Force -ErrorAction SilentlyContinue

# 4. Remove the installation receipt
if ($env:XDG_CONFIG_HOME) {
    Remove-Item "$env:XDG_CONFIG_HOME\color-ssh" -Recurse -Force -ErrorAction SilentlyContinue
} else {
    Remove-Item "$env:LOCALAPPDATA\color-ssh" -Recurse -Force -ErrorAction SilentlyContinue
}
```

### Shell Completion Cleanup

If you installed shell completions, remove them as well:

```bash
# Fish
rm -f ~/.config/fish/completions/colorsh.fish
rm -f ~/.config/fish/functions/__colorsh_fzf_complete.fish

# Zsh
# Remove the sourcing line from ~/.zshrc that references zsh-colorsh.zsh
```

---

## Uninstall

### Using Cargo

If you installed using cargo:

```bash
cargo uninstall color-ssh
```

Note: This only removes the binary. To completely remove configuration files and logs, also run:

```bash
rm -rf ~/.csh/
```

### Using Homebrew

If you installed using Homebrew:

```bash
brew uninstall color-ssh
```

### Linux/macOS (Manual)

If you installed using the installer script, follow these steps:

```bash
# 1. Remove the main binary
rm ~/.cargo/bin/csh

# 2. Remove the updater binary (if installed)
rm -f ~/.cargo/bin/color-ssh-update

# 3. Remove configuration and logs
rm -rf ~/.csh/

# 4. Remove the installation receipt
rm -rf ~/.config/color-ssh/
```

### Windows

If you installed using the PowerShell installer script:

```powershell
# 1. Remove the main binary
Remove-Item "$env:USERPROFILE\.cargo\bin\csh.exe" -Force

# 2. Remove the updater binary (if installed)
Remove-Item "$env:USERPROFILE\.cargo\bin\color-ssh-update.exe" -Force -ErrorAction SilentlyContinue

# 3. Remove configuration and logs
Remove-Item "$env:USERPROFILE\.csh" -Recurse -Force -ErrorAction SilentlyContinue

# 4. Remove the installation receipt
if ($env:XDG_CONFIG_HOME) {
    Remove-Item "$env:XDG_CONFIG_HOME\color-ssh" -Recurse -Force -ErrorAction SilentlyContinue
} else {
    Remove-Item "$env:LOCALAPPDATA\color-ssh" -Recurse -Force -ErrorAction SilentlyContinue
}
```

### Shell Completion Cleanup

If you installed shell completions, remove them as well:

```bash
# Fish
rm -f ~/.config/fish/completions/csh.fish
rm -f ~/.config/fish/functions/__csh_fzf_complete.fish

# Zsh
# Remove the sourcing line from ~/.zshrc that references zsh-csh.zsh
```

---

## Usage

### Basic Command Structure

```bash
colorsh [OPTIONS] <ssh_args>...
```

### Options

| Option | Description |
|--------|-------------|
| `-d, --debug` | Enable debug mode with detailed logging to `~/.colorsh/logs/colorsh.log` |
| `-l, --log` | Enable SSH session logging to `~/.colorsh/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
colorsh user@hostname

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

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

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

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

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

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

### Session Logs

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

```
~/.colorsh/logs/ssh_sessions/YYYY-MM-DD/HOSTNAME.log
```

Example:
```
~/.colorsh/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].colorsh-config.yaml`
2. **Home directory**: `~/.colorsh/[profile].colorsh-config.yaml`

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

### Configuration Profiles

Use profiles to maintain different configurations for different environments:

```bash
# Default profile
~/.colorsh/.colorsh-config.yaml

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

# Usage
colorsh -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.colorsh-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.colorsh-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/colorsh 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>