The author demonstrates a method for granting AI assistants secure access to server logs via SSH without exposing SSH keys. The approach utilizes the GateRook tool and the Model Context Protocol (MCP) to restrict AI capabilities to specific files, preventing unauthorized access to sensitive data like HTTP request logs.
A dedicated user account, logreader, is created on the server with permissions limited to specific directories and files. The setup involves configuring the gateway with a private key while ensuring the local AI client cannot access the key or the ssh-agent socket, which would bypass MCP security controls.
The configuration process includes defining a connection named shop-logs, specifying the host, user, and private key file. Access is granularly controlled by selecting specific files within the directory tree and setting read permissions. The system uses SFTP for directory navigation and restricted SSH commands for file reading.
The AI interacts with logs through three specific tools: ssh_logs_list for file discovery, ssh_logs_read for retrieving specific line counts or ranges, and ssh_logs_search for filtering entries by log levels and timestamps. The search tool supports pagination using cursors to handle large datasets.
Security management includes monitoring activity logs and pausing access points when not in use. The author notes that log rotation, such as renaming app.log to app.log.1, requires manual permission updates for the new file, as access rights are tied to specific filenames.




