How thxrhmn/hmpssh works
Main Components
• User Interface (CLI): Since the tool is terminal-based, the CLI is the primary presentation layer. It handles user inputs (like selecting add, connect, delete, backup, etc.) and displays connection lists.
• Application Logic: The core logic implemented in main.go, which coordinates the different features such as adding connections, connecting to servers, managing SSH keys, and handling backups.
• Configuration Management: A component responsible for reading from and writing to the config file (located at ~/.ssh/connections.conf) and managing SSH keys and file permissions.
• External Integrations:
– SSH Operations: Invoking system tools such as ssh, ssh-keygen, ssh-copy-id for actual SSH connections and key management.
– Backup/Restore Operations: Using tools like tar for configuration backup and extraction.
• File System & Persistence: This element represents interactions with the file system for saving configuration, SSH keys, and backup archives (stored in ~/ssh_backup).
Relationships and Interactions
• The CLI accepts user commands and relays them to the Application Logic.
• Application Logic processes the commands and, depending on the operation, interacts with the Configuration Management component (to persist or read connection settings).
• When an operation requires SSH actions or backups, the Application Logic hands off to External Integration components using system calls, which then interact with the underlying system's SSH tools or file system.
• In the backup/restore flow, the backup component uses tar to create or extract configuration archives.
Architectural Patterns and Design Principles
• Minimalist and Modular: Even though the project is simple, segmenting the CLI, application logic, configuration management, and integrations helps keep the architecture clean.
• Single Responsibility Principle: Each component (CLI, logic, configuration, integration) has a distinct role.
• Layered Interaction: Data flows from user input (CLI) through business logic to external system calls, showing a clear separation of concerns.
Relevant Technologies and Libraries
• Programming Language: Go (main.go, go.mod, go.sum).
• External Tools: ssh, ssh-keygen, ssh-copy-id, tar.
• OS/Filesystem: Interaction with directories such as ~/.ssh and ~/ssh_backup.