{"id":27000073,"url":"https://github.com/arec1b0/ssh-config-auditor","last_synced_at":"2025-04-04T03:18:43.766Z","repository":{"id":269641885,"uuid":"908056063","full_name":"arec1b0/ssh-config-auditor","owner":"arec1b0","description":"Python-based SSH Config Auditor","archived":false,"fork":false,"pushed_at":"2024-12-25T05:00:08.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-20T23:33:59.229Z","etag":null,"topics":["audit","security-tools","ssh","ssh-config"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arec1b0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":"auditor/__init__.py","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-25T02:20:05.000Z","updated_at":"2024-12-25T05:00:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f57caf7-5ce5-4ad2-a81d-a7704842a2f8","html_url":"https://github.com/arec1b0/ssh-config-auditor","commit_stats":null,"previous_names":["dkrizhanovskyi/ssh-config-auditor","arec1b0/ssh-config-auditor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fssh-config-auditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fssh-config-auditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fssh-config-auditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arec1b0%2Fssh-config-auditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arec1b0","download_url":"https://codeload.github.com/arec1b0/ssh-config-auditor/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112856,"owners_count":20885617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit","security-tools","ssh","ssh-config"],"created_at":"2025-04-04T03:18:43.262Z","updated_at":"2025-04-04T03:18:43.756Z","avatar_url":"https://github.com/arec1b0.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **SSH Config Auditor**\n\nA Python-based auditor that inspects SSH server configurations for security best practices. This tool checks parameters like **PasswordAuthentication**, **PermitRootLogin**, and **Port** settings to ensure a hardened setup. It can be used both as a **CLI** tool and a **FastAPI** service.\n\n---\n\n## **Table of Contents**\n1. [Features](#features)  \n2. [Architecture Overview](#architecture-overview)  \n3. [Prerequisites](#prerequisites)  \n4. [Installation](#installation)  \n5. [Usage](#usage)  \n   - [CLI Usage](#cli-usage)  \n   - [FastAPI Usage](#fastapi-usage)  \n6. [Testing](#testing)  \n7. [Docker / Podman](#docker--podman)  \n8. [Security Considerations](#security-considerations)  \n9. [Contributing](#contributing)\n\n---\n\n## **Features**\n- **CLI Interface** for local or automated audits.\n- **FastAPI Web Interface** for initiating and reviewing audits via REST API.\n- **Paramiko** integration to securely connect and fetch SSH configurations.\n- **Modular Architecture** to add or remove checks easily.\n- **Optional PDF Reporting** for audit documentation (via ReportLab).\n- **Unit Tests** with pytest to ensure robust functionality.\n\n---\n\n## **Architecture Overview**\n\n```bash\nssh-config-auditor\n├── auditor\n│   ├── api.py        # FastAPI endpoints\n│   ├── checks        # SSH checks (ssh_config_checks.py)\n│   ├── main.py       # CLI entry point\n│   ├── reports       # Optional PDF reporting\n│   └── utils         # Parsing utilities, helpers\n├── tests             # Pytest-based tests\n├── requirements.txt  # Python dependencies\n├── Dockerfile        # Container build file\n└── README.md\n```\n\n**Key Modules**:\n\n- **checks/**: Contains the core SSH auditing logic in `ssh_config_checks.py`.  \n- **main.py**: Primary CLI entry point, handling user inputs and orchestrating checks.  \n- **api.py**: FastAPI application for REST-based interactions.  \n- **reports/**: PDF and other reporting modules.  \n\n---\n\n## **Prerequisites**\n\n1. **Python 3.9+**  \n2. **pip** (Python package manager)  \n3. **(Optional)** **Docker / Podman** for containerized deployment\n\nOn Fedora or other Linux distributions, ensure you have basic build tools if using cryptography libraries:\n\n```bash\nsudo dnf install gcc openssl-devel libffi-devel\n```\n\n---\n\n## **Installation**\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone https://github.com/dkrizhanovskyi/ssh-config-auditor.git\n   cd ssh-config-auditor\n   ```\n\n   Or via SSH:\n\n   ```bash\n   git clone git@github.com:dkrizhanovskyi/ssh-config-auditor.git\n   cd ssh-config-auditor\n   ```\n\n2. **Create and Activate a Virtual Environment**:\n\n   ```bash\n   python3 -m venv .venv\n   source .venv/bin/activate\n   ```\n\n3. **Install Dependencies**:\n\n   ```bash\n   pip install --upgrade pip\n   pip install -r requirements.txt\n   ```\n\n---\n\n## **Usage**\n\n### **CLI Usage**\nRun the CLI directly via the `main.py` script:\n```bash\npython auditor/main.py --host 192.168.1.10 \\\n                       --user root \\\n                       --port 22 \\\n                       --password SECRET\n```\n\n**Arguments**:\n- `--host` (required): Target SSH server IP or hostname.  \n- `--user` (default: `root`): SSH username.  \n- `--port` (default: `22`): SSH port.  \n- `--key` (optional): Path to a private key for key-based auth.  \n- `--password` (optional): SSH password if not using key-based auth.\n\n### **FastAPI Usage**\n1. **Launch** the FastAPI service:\n   ```bash\n   uvicorn auditor.api:app --host 0.0.0.0 --port 8000\n   ```\n2. **Open** a browser at:\n   ```\n   http://127.0.0.1:8000/docs\n   ```\n3. **Invoke** the `/audit` endpoint with a JSON payload specifying `host`, `username`, etc.\n\n---\n\n## **Testing**\nUse **pytest** for running unit tests:\n\n1. **Activate** your virtual environment:\n   ```bash\n   source .venv/bin/activate\n   ```\n2. **Execute** the tests:\n   ```bash\n   pytest --maxfail=1 --disable-warnings\n   ```\n3. **(Optional)** Test coverage:\n   ```bash\n   pip install pytest-cov\n   pytest --cov=auditor tests/\n   ```\n\n---\n\n## **Docker / Podman**\n\n### **Build the Image**\n```bash\npodman build -t ssh-config-auditor:latest .\n```\nOr if you prefer Docker:\n```bash\ndocker build -t ssh-config-auditor:latest .\n```\n\n### **Run the Container**\n```bash\npodman run -p 8000:8000 \\\n           --name auditor \\\n           -d ssh-config-auditor:latest\n```\n\nIf you see an error about an existing container, remove or replace it:\n```bash\npodman rm -f auditor\npodman run --replace -p 8000:8000 \\\n           --name auditor \\\n           -d ssh-config-auditor:latest\n```\n\nAccess the FastAPI docs at:  \n```\nhttp://127.0.0.1:8000/docs\n```\n\n---\n\n## **Security Considerations**\n- **SSH Keys**: Avoid storing private keys in plain text or in the repo; use environment variables or secret managers (e.g., HashiCorp Vault).  \n- **Logging**: Consider signing logs or storing them in an append-only system for tamper resistance.  \n- **API Authentication**: Secure exposed endpoints with token-based auth or BasicAuth if deploying publicly.  \n- **Least Privilege**: Limit the SSH user to read-only permissions for `/etc/ssh/sshd_config`.  \n\n---\n\n## **Contributing**\n1. **Fork** the project \u0026 create a feature branch from `develop`.  \n2. **Implement** your changes, adding relevant tests.  \n3. **Commit** with descriptive messages.  \n4. **Open** a pull request towards `develop`.  \n5. **Ensure** all tests and lint checks pass before merging.\n\nFor major features or design changes, please open an issue to discuss them first!\n\n---\n\n**Thank you for using SSH Config Auditor!**  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farec1b0%2Fssh-config-auditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farec1b0%2Fssh-config-auditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farec1b0%2Fssh-config-auditor/lists"}