listKnownHosts
Retrieve a consolidated list of all known SSH hosts by prioritizing ~/.ssh/config entries and supplementing with ~/.ssh/known_hosts data for comprehensive host management.
Instructions
Returns a consolidated list of all known SSH hosts, prioritizing ~/.ssh/config entries first, then additional hosts from ~/.ssh/known_hosts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/ssh-client.ts:17-19 (handler)The handler function that executes the 'listKnownHosts' tool logic, delegating to SSHConfigParser's getAllKnownHosts method.async listKnownHosts(): Promise<SSHHostInfo[]> { return await this.configParser.getAllKnownHosts(); }
- src/types.ts:2-9 (schema)Interface defining the structure of SSHHostInfo returned by the listKnownHosts tool.export interface SSHHostInfo { hostname: string; alias?: string; user?: string; port?: number; identityFile?: string; [key: string]: any; // For other configuration options }
- src/ssh-config-parser.ts:100-116 (helper)Supporting method that implements the core logic for retrieving and consolidating known SSH hosts from both config and known_hosts files.async getAllKnownHosts(): Promise<SSHHostInfo[]> { const configHosts = await this.parseConfig(); const knownHostnames = await this.parseKnownHosts(); // Add hosts from known_hosts that aren't in the config for (const hostname of knownHostnames) { if (!configHosts.some(host => host.hostname === hostname || host.alias === hostname)) { configHosts.push({ hostname: hostname }); } } return configHosts; }