getHostInfo
Retrieve configuration details for a specified SSH host using its alias or hostname, facilitating secure and informed interactions with remote systems.
Instructions
Returns all configuration details for an SSH host
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostAlias | Yes | Alias or hostname of the SSH host |
Implementation Reference
- src/ssh-client.ts:52-55 (handler)The handler function that implements the getHostInfo tool. It parses the SSH config and finds the host matching the given alias or hostname.async getHostInfo(hostAlias: string): Promise<SSHHostInfo | null> { const hosts = await this.configParser.parseConfig(); return hosts.find(host => host.alias === hostAlias || host.hostname === hostAlias) || null; }
- src/types.ts:2-9 (schema)Type definition for the SSHHostInfo interface, which is the return type of the getHostInfo 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:20-29 (helper)The parseConfig method called by getHostInfo to load and parse the SSH configuration file into host information.async parseConfig(): Promise<SSHHostInfo[]> { try { const content = await readFile(this.configPath, 'utf-8'); const config = sshConfig.parse(content); return this.extractHostsFromConfig(config); } catch (error) { console.error('Error reading SSH config:', error); return []; } }