ssh-search

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 5 Imported by: 0

README

Tests Go Report Card

A fast command-line tool written in Go to search through your SSH config file and find matching hosts, usernames, and hostnames.

Features

  • Blazingly fast - Written in Go for optimal performance
  • Case-insensitive search through SSH config file
  • Searches through host aliases, usernames, and hostnames
  • Shows results in an easy-to-read format: hostname (user@host)
  • Single binary with no runtime dependencies
  • Works on MacOS and Linux

Installation

Homebrew (macOS/Linux)
brew install gido/tap/ssh-search
Download Binary

Download the latest pre-built binary for your platform from the releases page.

macOS:

# Apple Silicon (M1/M2/M3)
curl -L https://github.com/gido/ssh-search/releases/latest/download/ssh-search_Darwin_arm64.tar.gz | tar xz
sudo mv ssh-search /usr/local/bin/

# Intel
curl -L https://github.com/gido/ssh-search/releases/latest/download/ssh-search_Darwin_x86_64.tar.gz | tar xz
sudo mv ssh-search /usr/local/bin/

Linux:

# x86_64
curl -L https://github.com/gido/ssh-search/releases/latest/download/ssh-search_Linux_x86_64.tar.gz | tar xz
sudo mv ssh-search /usr/local/bin/

# ARM64
curl -L https://github.com/gido/ssh-search/releases/latest/download/ssh-search_Linux_arm64.tar.gz | tar xz
sudo mv ssh-search /usr/local/bin/

Windows:

# Download from releases page or use winget/scoop (coming soon)
Go Install

If you have Go installed:

go install github.com/gido/ssh-search@latest
Build from Source

Prerequisites: Go 1.21 or later

git clone https://github.com/gido/ssh-search.git
cd ssh-search
go build -o ssh-search
sudo mv ssh-search /usr/local/bin/

Usage

ssh-search <search_term>
Examples
# Search for development servers
ssh-search dev

# Search for production servers
ssh-search prod

# Search by username
ssh-search john

# Search by hostname
ssh-search example.com

How it Works

The script reads your SSH config file (default location: ~/.ssh/config) and searches through all entries for matches in:

  • Host aliases
  • Usernames
  • Hostnames

When a match is found, it displays the host entry in the format: hostname (user@host)

Development

Building
# Install dependencies
go mod download

# Build
go build -o ssh-search

# Run
./ssh-search <search_term>
Running Tests

The project includes a comprehensive Go test suite with 15+ test cases:

# Run all tests
go test

# Run tests with verbose output
go test -v

# Run tests with coverage
go test -cover

# Run specific test
go test -run TestSearchHosts

The test suite covers:

  • SSH config parsing
  • Host name searching
  • Username searching
  • Hostname/domain searching
  • Case-insensitive matching
  • Partial matches
  • Edge cases (no user, no hostname, wildcards)
  • Special characters and IP addresses
  • Format output validation
Implementation Notes

The Go version uses the github.com/kevinburke/ssh_config library for robust SSH config parsing, including support for:

  • Both HostName and Hostname capitalization variants
  • Comment preservation
  • Wildcard pattern matching
  • Include directives

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Version History

  • v2.0 - Complete rewrite in Go for significantly improved performance
  • v1.0 - Original bash implementation

Acknowledgments

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL