{"id":13522506,"url":"https://github.com/cloudposse/bastion","last_synced_at":"2026-01-29T21:13:45.883Z","repository":{"id":16980763,"uuid":"80958321","full_name":"cloudposse/bastion","owner":"cloudposse","description":"🔒Secure Bastion implemented as Docker Container running Alpine Linux with Google Authenticator \u0026 DUO MFA support","archived":false,"fork":false,"pushed_at":"2025-12-24T17:18:38.000Z","size":1420,"stargazers_count":669,"open_issues_count":3,"forks_count":113,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-12-25T19:46:21.860Z","etag":null,"topics":["alpine","bastion","docker","dockerfile","duo","google-authenticator","linux","mfa","openssh","slack"],"latest_commit_sha":null,"homepage":"cloudposse.com/accelerate","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudposse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"cloudposse"}},"created_at":"2017-02-05T00:27:58.000Z","updated_at":"2025-12-19T08:37:33.000Z","dependencies_parsed_at":"2022-08-23T15:31:18.180Z","dependency_job_id":"1dd74ac7-160c-4b24-b373-6d0f7734900b","html_url":"https://github.com/cloudposse/bastion","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/cloudposse/bastion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudposse%2Fbastion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudposse%2Fbastion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudposse%2Fbastion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudposse%2Fbastion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudposse","download_url":"https://codeload.github.com/cloudposse/bastion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudposse%2Fbastion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28885244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T21:06:44.224Z","status":"ssl_error","status_checked_at":"2026-01-29T21:06:42.160Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["alpine","bastion","docker","dockerfile","duo","google-authenticator","linux","mfa","openssh","slack"],"created_at":"2024-08-01T06:00:48.187Z","updated_at":"2026-01-29T21:13:45.875Z","avatar_url":"https://github.com/cloudposse.png","language":"Shell","readme":"\n\n\u003c!-- markdownlint-disable --\u003e\n\u003ca href=\"https://cpco.io/homepage\"\u003e\u003cimg src=\"https://github.com/cloudposse/bastion/blob/main/.github/banner.png?raw=true\" alt=\"Project Banner\"/\u003e\u003c/a\u003e\u003cbr/\u003e\n\n\n\u003cp align=\"right\"\u003e\u003ca href=\"https://github.com/cloudposse/bastion/releases/latest\"\u003e\u003cimg src=\"https://img.shields.io/github/release/cloudposse/bastion.svg\" alt=\"Latest Release\"/\u003e\u003c/a\u003e\u003ca href=\"https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml\"\u003e\u003cimg src=\"https://github.com/cloudposse/bastion/actions/workflows/integration-tests.yml/badge.svg\" alt=\"Build \u0026 Test Status\"/\u003e\u003c/a\u003e\u003ca href=\"https://slack.cloudposse.com\"\u003e\u003cimg src=\"https://slack.cloudposse.com/badge.svg\" alt=\"Slack Community\"/\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n\u003c!--\n\n\n\n\n  ** DO NOT EDIT THIS FILE\n  **\n  ** This file was automatically generated by the `cloudposse/build-harness`.\n  ** 1) Make all changes to `README.yaml`\n  ** 2) Install [atmos](https://atmos.tools/install/) (you only need to do this once)\n  ** 3) Run`atmos readme` to rebuild this file.\n  **\n  ** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)\n  **\n\n\n\n\n\n--\u003e\n\nThis is a secure/locked-down bastion implemented as a Docker Container. It uses Alpine Linux as the base image and ships with support for Google Authenticator \u0026 DUO MFA support.\n\nIt was designed to be used on Kubernetes together with [GitHub Authorized Keys](https://github.com/cloudposse/github-authorized-keys) to provide secure remote access to production clusters.\n### MFA Setup \u0026 Usage\n\nHere's a demo of what a user experiences when setting up Google Authenticator for the first time.\n\n![Demo 1](docs/demo.gif)\n\nWhen using Duo as the MFA provider, this becomes even more magical because Duo supports automatic Push notifications to your mobile device.\nJust approve the request on your mobile phone (e.g. with a thumb press on iOS) when prompted.\n\n### Slack Notifications\n\nHere's what it looks like when someone connects to the bastion if Slack notifications are enabled.\n\n![Demo 2](docs/slack.png)\n\nWe recommend using Slack notifications for self-reporting.\n* Any time a user accesses production systems, they should reply to the slack notification to justify their remote access.\n* A \"buddy\" should approve the login by adding a reaction (e.g. ✅).\n* If no one approves the login, it should trigger an *incident response* to track down the unauthorized access.\n\n\n\n\n\n\n\n## Usage\n\n### Running\n\nRefer to the [Environment Variables](#environment-variables) section below to tune how the `bastion` operates.\n\n\n```bash\n$ docker run -p 1234:22 cloudposse/bastion:latest\n```\n\n### Building\n\n```bash\n$ git clone https://github.com/cloudposse/bastion.git\n$ cd bastion\n$ make docker:build\n```\n\n### Testing\n\nRun basic connection tests\n\n```bash\n$ make test\n```\n\n### Configuration\n\n## Recommendations\n\n* Do not allow `root` (or `sudo`) access to this container as doing so would allow remote users to manipulate audit-logs in `/var/log/sudo-io`\n* Use the bastion as a \"jump host\" for accessing other internal systems rather than installing a lot of unnecessary stuff, which increases the overall attack surface.\n* Sync the contents of `/var/log/sudo-io` to a remote, offsite location. If using S3, we recommend enabling bucket-versioning.\n* Use [`github-authorized-keys](https://github.com/cloudposse/github-authorized-keys/) to automatically provision users; or use the [Helm chart](https://github.com/cloudposse/charts/tree/master/incubator/bastion).\n* Bind-mount `/etc/passwd`, `/etc/shadow` and `/etc/group` into the container as *read-only*\n* Bind-mount `/home` into container; the bastion does not manage authorized keys\n\n#### Environment Variables\n\nThe following tables lists the most relevant environment variables of the `bastion` image and their default values.\n\n##### Duo Settings\n\nDuo is a enterprise MFA provider that is very affordable. Details here: https://duo.com/pricing\n\n\n| ENV               |      Description                                    |  Default |\n|-------------------|:----------------------------------------------------|:--------:|\n| `MFA_PROVIDER`    |  Enable the Duo MFA provider                        | duo      |\n| `DUO_IKEY`        |  Duo Integration Key                                |          |\n| `DUO_SKEY`        |  Duo Secret Key                                     |          |\n| `DUO_HOST`        |  Duo Host Endpoint                                  |          |\n| `DUO_FAILMODE`    |  How to fail if Duo cannot be reached               | secure   |\n| `DUO_AUTOPUSH`    |  Automatically send a push notification             | yes      |\n| `DUO_PROMPTS`     |  How many times to prompt for MFA                   | 1        |\n\n\n##### Google Authenticator Settings\n\nGoogle Authenticator is a free \u0026 open source MFA solution. It's less secure than Duo because tokens are stored on the server under each user account.\n\n\n| ENV               |      Description                                    |  Default              |\n|-------------------|:----------------------------------------------------|:---------------------:|\n| `MFA_PROVIDER`    |  Enable the Google Authenticator provider           | google-authenticator  |\n\n\n##### Enforcer Settings\n\nThe enforcer ensures certain conditions are satisfied. Currently, these options are supported.\n\n| ENV                           |  Description                                                 |  Default |\n|-------------------------------|:-------------------------------------------------------------|:--------:|\n| `ENFORCER_ENABLED`            |  Enable general enforcement                                  | `true`   |\n| `ENFORCER_CLEAN_HOME_ENABLED` |  Erase dot files in home directory before starting session   | `true`   |\n\n##### Slack Notifications\n\nThe enforcer is able to send notifications to a slack channel anytime there is an SSH login.\n\n| ENV                        |      Description                                    |  Default  |\n|----------------------------|:----------------------------------------------------|:---------:|\n| `SLACK_ENABLED`            | Enabled Slack integration                           | `false`   |\n| `SLACK_HOOK`               | Slack integration method (e.g. `pam`, `sshrc`)      | `sshrc`   |\n| `SLACK_WEBHOOK_URL`        | Webhook URL                                         |           |\n| `SLACK_USERNAME`           | Slack handle of bot (defaults to short-dns name)    |           |\n| `SLACK_TIMEOUT`            | Request timeout                                     | `2`       |\n| `SLACK_FATAL_ERRORS`       | Deny logins if slack notification fails             | `true`    |\n\n\n##### SSH Auditor\n\nThe SSH auditor uses [`sudosh`](https://github.com/cloudposse/sudosh/) to record entire SSH sessions (`stdin`, `stdout`, and `stderr`).\n\n\n| ENV                   |      Description                                    |  Default     |\n|-----------------------|:----------------------------------------------------|:------------:|\n| `SSH_AUDIT_ENABLED`   |  Enable the SSH Audit facility                      | `true`       |\n\nThis will require that users login with the `/usr/bin/sudosh` shell.\n\nUpdate user's default shell by running the command: `usermod -s /usr/bin/sudosh $username`. By default, `root` will automatically be updated to use `sudosh`.\n\nUse the `sudoreplay` command to audit/replay sessions.\n\n\n#### User Accounts \u0026 SSH Keys\n\nThe `bastion` does not attempt to manage user accounts. We suggest using [GitHub Authorized Keys](https://github.com/cloudposse/github-authorized-keys) to provision user accounts and SSH keys. We provide a [chart](https://github.com/cloudposse/charts/tree/master/incubator/bastion) of how we recommend doing it.\n\n### Extending\n\nThe `bastion` was written to be easily extensible.\n\nYou can extend the enforcement policies by adding shell scripts to `etc/enforce.d`. Any scripts that are `+x` (e.g. `chmod 755`) will be executed at runtime.\n\n## Thanks\n\n- [@neochrome](https://github.com/neochrome/docker-bastion), for providing a great basic bastion built on top of Alpine Linux\n- [@aws](https://aws.amazon.com/blogs/security/how-to-record-ssh-sessions-established-through-a-bastion-host/), for providing detailed instructions on how to do SSH session logging.\n- [@duo](https://duo.com/docs/duounix), for providing excellent documentation\n- [@google](https://github.com/google/google-authenticator-libpam) for contributing Google Authenticator to the Open Source community\n\n\n## Quick Start\n\n\nHere's how you can quickly demo the `bastion`. We assume you have `~/.ssh/authorized_keys` properly configured and your SSH key (e.g. `~/.ssh/id_rsa`) added to your SSH agent.\n\n\n```bash\n$ docker run -it -p 1234:22 \\\n     -e MFA_PROVIDER=google-authenticator \\\n     -v ~/.ssh/authorized_keys:/root/.ssh/authorized_keys \\\n     cloudposse/bastion\n```\n\nNow, in another terminal you should be able to run:\n```bash\n$ ssh root@localhost -p 1234\n```\n\nThe first time you connect, you'll be asked to setup your MFA device. Subsequently, each time you connect, you'll be prompted to enter your MFA token.\n\n\n\n\n\n\n\n\n\n\n\n## ✨ Contributing\n\nThis project is under active development, and we encourage contributions from our community.\n\n\n\nMany thanks to our outstanding contributors:\n\n\u003ca href=\"https://github.com/cloudposse/bastion/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=cloudposse/bastion\u0026max=24\" /\u003e\n\u003c/a\u003e\n\nFor 🐛 bug reports \u0026 feature requests, please use the [issue tracker](https://github.com/cloudposse/bastion/issues).\n\nIn general, PRs are welcome. We follow the typical \"fork-and-pull\" Git workflow.\n 1. Review our [Code of Conduct](https://github.com/cloudposse/bastion/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md).\n 2. **Fork** the repo on GitHub\n 3. **Clone** the project to your own machine\n 4. **Commit** changes to your own branch\n 5. **Push** your work back up to your fork\n 6. Submit a **Pull Request** so that we can review your changes\n\n**NOTE:** Be sure to merge the latest changes from \"upstream\" before making a pull request!\n\n### 🌎 Slack Community\n\nJoin our [Open Source Community](https://cpco.io/slack?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=cloudposse/bastion\u0026utm_content=slack) on Slack. It's **FREE** for everyone! Our \"SweetOps\" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.\n\n### 📰 Newsletter\n\nSign up for [our newsletter](https://cpco.io/newsletter?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=cloudposse/bastion\u0026utm_content=newsletter) and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know.\nDropped straight into your Inbox every week — and usually a 5-minute read.\n\n### 📆 Office Hours \u003ca href=\"https://cloudposse.com/office-hours?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=cloudposse/bastion\u0026utm_content=office_hours\"\u003e\u003cimg src=\"https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png\" align=\"right\" /\u003e\u003c/a\u003e\n\n[Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=cloudposse/bastion\u0026utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q\u0026A_ that you can’t find anywhere else.\nIt's **FREE** for everyone!\n## License\n\n\u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ePreamble to the Apache License, Version 2.0\u003c/summary\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\nComplete license is available in the [`LICENSE`](LICENSE) file.\n\n```text\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\n  https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n```\n\u003c/details\u003e\n\n## Trademarks\n\nAll other trademarks referenced herein are the property of their respective owners.\n\n\n---\nCopyright © 2017-2026 [Cloud Posse, LLC](https://cpco.io/copyright)\n\n\n\u003ca href=\"https://cloudposse.com/readme/footer/link?utm_source=github\u0026utm_medium=readme\u0026utm_campaign=cloudposse/bastion\u0026utm_content=readme_footer_link\"\u003e\u003cimg alt=\"README footer\" src=\"https://cloudposse.com/readme/footer/img\"/\u003e\u003c/a\u003e\n\n\u003cimg alt=\"Beacon\" width=\"0\" src=\"https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/bastion?pixel\u0026cs=github\u0026cm=readme\u0026an=bastion\"/\u003e\n","funding_links":["https://github.com/sponsors/cloudposse"],"categories":["Bastion Host","Shell","linux"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudposse%2Fbastion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudposse%2Fbastion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudposse%2Fbastion/lists"}