get_ssh_config
Retrieve SSH server (sshd) configuration settings including port, authentication methods, and security options to audit or verify current setup.
Instructions
Get SSH server (sshd) configuration settings including port, authentication methods, and security options.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | No | Server alias (e.g., 'pi1', 'web-server'). Uses default server if not specified. |
Implementation Reference
- src/tools/admin.py:109-173 (handler)The main handler function for the get_ssh_config tool. Calls Webmin's sshd::get_sshd_config via XML-RPC, parses common SSH settings (port, auth methods, etc.) with fallback for lowercase keys, and returns them as a ToolResult.
async def get_ssh_config(client: WebminClient) -> ToolResult: """Get SSH server (sshd) configuration. Returns key SSH daemon configuration settings. Args: client: Authenticated WebminClient instance. Returns: ToolResult with SSH configuration. """ try: config_raw = await client.call("sshd", "get_sshd_config") if isinstance(config_raw, dict): # Parse common SSH settings config = { "port": config_raw.get("Port", config_raw.get("port")), "permit_root_login": config_raw.get( "PermitRootLogin", config_raw.get("permit_root_login") ), "password_authentication": config_raw.get( "PasswordAuthentication", config_raw.get("password_authentication") ), "pubkey_authentication": config_raw.get( "PubkeyAuthentication", config_raw.get("pubkey_authentication") ), "x11_forwarding": config_raw.get( "X11Forwarding", config_raw.get("x11_forwarding") ), "max_auth_tries": config_raw.get( "MaxAuthTries", config_raw.get("max_auth_tries") ), "permit_empty_passwords": config_raw.get( "PermitEmptyPasswords", config_raw.get("permit_empty_passwords") ), "challenge_response": config_raw.get( "ChallengeResponseAuthentication", config_raw.get("challenge_response_authentication"), ), "use_pam": config_raw.get("UsePAM", config_raw.get("use_pam")), "listen_address": config_raw.get( "ListenAddress", config_raw.get("listen_address") ), "protocol": config_raw.get("Protocol", config_raw.get("protocol")), "config_file": config_raw.get("file"), } # Clean up None values for readability config = {k: v for k, v in config.items() if v is not None} return ToolResult.ok({ "settings": config, "raw_config": config_raw, }) else: return ToolResult.ok({ "raw": config_raw, }) except Exception as e: return ToolResult.fail( code="SSH_CONFIG_ERROR", message=f"Failed to get SSH configuration: {e}", ) - src/server.py:860-871 (registration)Registration of the get_ssh_config tool in the TOOLS list with its MCP metadata (name, description, input schema). Only accepts the optional 'server' parameter for multi-server support.
Tool( name="get_ssh_config", description=( "Get SSH server (sshd) configuration settings including port, " "authentication methods, and security options." ), inputSchema={ "type": "object", "properties": {**SERVER_PARAM}, "required": [], }, ), - src/server.py:1721-1722 (registration)Dispatch in call_tool handler that routes 'get_ssh_config' tool calls to the admin.get_ssh_config() handler function.
if name == "get_ssh_config": return await admin.get_ssh_config(client) - src/models.py:35-67 (helper)ToolResult helper model used by get_ssh_config to wrap success/failure responses with data or error details.
class ToolResult(BaseModel): """Generic result wrapper for MCP tool responses.""" success: bool = Field( description="Whether the operation succeeded", ) data: dict[str, Any] | None = Field( default=None, description="Result data on success", ) error: WebminError | None = Field( default=None, description="Error details on failure", ) @classmethod def ok(cls, data: dict[str, Any]) -> "ToolResult": """Create a successful result.""" return cls(success=True, data=data) @classmethod def fail( cls, code: str, message: str, details: dict[str, Any] | None = None, ) -> "ToolResult": """Create a failure result.""" return cls( success=False, error=WebminError(code=code, message=message, details=details), )