ssh_grep
Search remote file contents over SSH using regex, returning matching files, lines with numbers and context, or counts, with optional glob filters.
Instructions
Search remote file contents over SSH — the remote counterpart of the local content-search tool. Backed by remote grep (PCRE-like -P when available, otherwise POSIX extended regex), recursing under 'path' while skipping .git/.hg/.svn. Defaults to 'files_with_matches' mode for efficiency; use 'content' mode for matching lines with line numbers and optional context.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | Glob filter for which filenames to search, e.g. '*.py' or '*.{ts,tsx}'. | |
| path | No | Remote file or directory to search. Default: '.' (the SSH login directory). | |
| port | No | ||
| target | Yes | OpenSSH target such as host, alias, or user@host. | |
| context | No | Lines of context before and after each match. Only applies to output_mode='content'. | |
| pattern | Yes | Regular expression to search for. | |
| timeout | No | Local timeout in seconds. | |
| head_limit | No | Cap the number of returned matches/files. | |
| output_mode | No | 'content': matching lines with line numbers (supports context). 'files_with_matches': just the matching paths (default). 'count': per-file match counts (files with zero matches are omitted). | |
| context_after | No | Lines of context after each match. Overridden by 'context' if both are given. | |
| identity_file | No | ||
| context_before | No | Lines of context before each match. Overridden by 'context' if both are given. | |
| extra_ssh_args | No | Additional ssh(1) flags passed verbatim, e.g. ["-J", "jumphost"]. Prefer the dedicated port, identity_file, and strict_host_key_checking parameters. | |
| case_insensitive | No | Case-insensitive search. Default: false. | |
| known_hosts_file | No | ||
| strict_host_key_checking | No | Boolean or one of yes, no, ask, accept-new, off. |