{"id":13626132,"url":"https://github.com/xen0l/aws-gate","last_synced_at":"2026-01-02T13:05:00.239Z","repository":{"id":37828958,"uuid":"158130806","full_name":"xen0l/aws-gate","owner":"xen0l","description":"Better  AWS SSM Session manager CLI client ","archived":false,"fork":false,"pushed_at":"2024-06-03T03:37:19.000Z","size":467,"stargazers_count":514,"open_issues_count":33,"forks_count":41,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T13:09:19.561Z","etag":null,"topics":["access-control","aws","aws-ssm","aws-ssm-agent","cli","ec2","ec2-instances","hardening","iam-access","scp","session-manager","ssh","ssh-session","ssh-support"],"latest_commit_sha":null,"homepage":"https://aws-gate.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xen0l.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-18T21:56:15.000Z","updated_at":"2025-03-28T15:39:18.000Z","dependencies_parsed_at":"2024-11-08T15:34:44.778Z","dependency_job_id":"d9ae85fd-662c-4d2c-b805-f61d9871920b","html_url":"https://github.com/xen0l/aws-gate","commit_stats":{"total_commits":425,"total_committers":21,"mean_commits":"20.238095238095237","dds":0.6799999999999999,"last_synced_commit":"a9bb7d9618f76b9a27375b2cc5cd91068276f809"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xen0l%2Faws-gate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xen0l%2Faws-gate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xen0l%2Faws-gate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xen0l%2Faws-gate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xen0l","download_url":"https://codeload.github.com/xen0l/aws-gate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249235051,"owners_count":21235137,"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":["access-control","aws","aws-ssm","aws-ssm-agent","cli","ec2","ec2-instances","hardening","iam-access","scp","session-manager","ssh","ssh-session","ssh-support"],"created_at":"2024-08-01T21:02:10.807Z","updated_at":"2026-01-02T13:04:55.208Z","avatar_url":"https://github.com/xen0l.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# aws-gate\n![Build Status](https://github.com/xen0l/aws-gate/actions/workflows/python-package.yml/badge.svg?branch=master)[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![codecov](https://codecov.io/gh/xen0l/aws-gate/branch/master/graph/badge.svg)](https://codecov.io/gh/xen0l/aws-gate)[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f4385e925e34788a20e40b4a3319b2d)](https://app.codacy.com/app/xen0l/aws-gate?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=xen0l/aws-gate\u0026utm_campaign=Badge_Grade_Settings)[![PyPI version](https://badge.fury.io/py/aws-gate.svg)](https://badge.fury.io/py/aws-gate)![PyPI - Downloads](https://img.shields.io/pypi/dm/aws-gate)\n\nAWS SSM Session manager client\n\n[Documentation](https://aws-gate.readthedocs.io)\n\n## Motivation\n\nI am using AWS a lot and I am tired of dealing with everything that comes with the bastion host (additional instance one has to maintain, distribute SSH keys (shared SSH keys are not an option for me), exposing SSH to the network). A while ago, Amazon released a service to fix this - [AWS Systems Manager Session Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html). However, CLI user experience of Session Manager is limited and lacks some features:\n\n* ability to connect to instances by other means (e.g. DNS, IP, tag, instance name, autoscaling group) as aws cli supports only connecting by instance IDs\n* configuration file support for storing connection information via Session Manager\n\n*aws-gate* tries to address these issues.\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.\n\n### Prerequisites\n\n* Python 3.5+ (earlier Python 3 versions should work too)\n* [session-plugin-manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html) from AWS\n* SSM Agent version 2.3.68.0 or later must be installed on EC2 instances we want to connect to\n* Proper IAM permissions for instance profile\n\n### Installing\n\nVia pip\n\n```\npip install aws-gate\n```\n\nor via Homebrew\n\n```\nbrew tap xen0l/homebrew-taps\nbrew install aws-gate\n\n# For installing session-manager-plugin via Homebrew (optional)\nbrew install --cask session-manager-plugin\n```\n\n\nor via Docker\n\n```\ndocker login docker.pkg.github.com -u $YOUR_GH_USERNAME -p $GH_TOKEN\ndocker pull docker.pkg.github.com/xen0l/aws-gate/aws-gate:latest\n```\n\n### Features\n\n#### config and config.d support\n\nYou can store information about to connect to your instance (name, region and profile) and *aws-gate* will do everything for you. The config file is stored in **~/.aws-gate/config** and has the following YAML syntax:\n\n```\nhosts:\n  - alias: backend-pre\n    name: backend\n    profile: preproduction\n    region: eu-west-1\n  - alias: backend-pro\n    name: backend\n    profile: production\n    region: eu-west-1\n\ndefaults:\n  profile: development\n  region: eu-west-1\n```\n\nwhere *hosts* stores connection information and *defaults* default configuration settings to use. To connect to instance _backend-pre_, execute:\n```\naws-gate session backend-pre\n```\n\nYou can place additional configuration files in **~/.aws-gate/config.d**. This is ideal when you are working on different projects or when you need to share configuration inside your team.\n\n#### Querying instances by different instance identifiers\n\n*aws-gate* supports querying for instances with following identifiers:\n\n* instance id\n```\naws-gate session i-0772e4c1dcdd763b6\n```\n* DNS name\n```\naws-gate session ec2-34-245-174-132.eu-west-1.compute.amazonaws.com\n```\n* private DNS name\n```\naws-gate session ip-172-31-35-113.eu-west-1.compute.internal\n```\n\n* IP address\n```\naws-gate session 34.245.174.13\n```\n\n* private IP address\n```\naws-gate session 172.31.35.113\n```\n\n* tags\n```\naws-gate session Name:SSM-test\n```\n\n* name (uses tag identifier under the hood)\n```\naws-gate session SSM-test\n```\n\n* autoscaling group name (uses tag identifier under the hood)\n```\naws-gate session asg:dummy-v001\n```\n\n#### SSH ProxyCommand support\n\nAWS SSM Session Manager supports tunneling SSH sessions over it. Moreover, _aws-gate_ supports generating ephemeral SSH\nkeys and uploading them via EC2 Instance Connect API. However, to use this functionality,\nEC2 Instance Connect [setup](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html) is needed.\n\nTo use this functionality, simply run **aws-gate ssh-config**, which will generate the required _~/.ssh/config_ snippet for you:\n```\n% aws-gate ssh-config\nHost *.eu-west-1.default\nIdentityFile /Users/xenol/.aws-gate/key\nIdentitiesOnly yes\nUser ec2-user\nPort 22\nProxyCommand sh -c \"aws-gate ssh-proxy -p `echo %h | sed -Ee 's/^(.*)\\.(.*)\\.(.*)$/\\\\3/g'` -r `echo %h | sed -Ee 's/^(.*)\\.(.*)\\.(.*)$/\\\\2/g'` `echo %h | sed -Ee 's/^(.*)\\.(.*)\\.(.*)$/\\\\1/g'`\"\n```\n\nStore the snippet inside _~/.ssh/config_:\n```\n% aws-gate ssh-config \u003e\u003e ~/.ssh/config\n```\n\nThen connect via *ssh*:\n```\n% ssh ssm-test.eu-west-1.default\nLast login: Fri Oct  4 17:17:02 2019 from localhost\n\n       __|  __|_  )\n       _|  (     /   Amazon Linux 2 AMI\n      ___|\\___|___|\n\nhttps://aws.amazon.com/amazon-linux-2/\n1 package(s) needed for security, out of 20 available\nRun \"sudo yum update\" to apply all updates.\n[ec2-user@ip-172-31-35-173 ~]$\n```\n\nSSH session to instance _ssm-test_ in eu-west-1 AWS region via _default_ AWS profile is opened.\n\n*scp* works the same way (both ways):\n```\n% # local to remote\n% scp test_file ssm-test.eu-west-1.glovoapp:test_file    \ntest_file                                                                                                                                                                 100%    0     0.0KB/s   00:00    \n%\n% # remote to local\n% scp ssm-test.eu-west-1.glovoapp:test_file test_file\ntest_file                                                                                                                                                                 100%    0     0.0KB/s   00:00    \n```\n\nPlease, also note that while **scp over SSM** works, it can be [extremely slow](https://globaldatanet.com/blog/scp-performance-with-ssm-agent). This is because of the underlying SSM limitations and not caused by **aws-gate itself**.\n\n#### SSH support\n\n*aws-gate* provides a way to open SSH session on the instance directly. This is achieved by wrapping around _ssh_ under the hood.\nSimply run **aws-gate ssh \u003cinstance_identifier\u003e**:\n\n```\n% aws-gate ssh ssm-test\nLast login: Sat Nov  9 10:23:11 2019 from localhost\n\n       __|  __|_  )\n       _|  (     /   Amazon Linux 2 AMI\n      ___|\\___|___|\n\nhttps://aws.amazon.com/amazon-linux-2/\n28 package(s) needed for security, out of 56 available\nRun \"sudo yum update\" to apply all updates.\n[ec2-user@ip-172-31-35-173 ~]$\n```\n\nIf you wish to execute a specific command (or plug it into your shell pipelines):\n\n```\n% aws-gate ssh ssm-test uname -a\nLinux ip-172-31-35-173.eu-west-1.compute.internal 4.14.123-111.109.amzn2.x86_64 #1 SMP Mon Jun 10 19:37:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux\n```\n\nLocal ports can be forwarded to another host and port relative to the target instance. This works as if by using ssh's `-L` option. Instead of executing a command, *aws-gate* establishes a forwarding session that can be used by other local applications.\n\nFor example, you can use this to connect to a private web server by forwarding the instance's local port.\n\n```\n# Terminal 1\n% aws-gate ssh -L 8888:localhost:80 ssh-test\n\n# Terminal 2\n% curl localhost:8888\n\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"\u003e\n\n\u003chtml xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eTest Page for the Nginx HTTP Server on Amazon Linux\u003c/title\u003e\n...\n```\n\nOr you can use it to connect to a private RDS instance by forwarding the remote address and remote port.\n\n```\n# Terminal 1\n% aws-gate ssh -L 3306:privatedb.abcdef123456.eu-west-1.rds.amazonaws.com:3306 ssm-test\n\n# Terminal 2\n% mysql -h 127.0.0.1 -u root -P 3306 -p -e \"SELECT User from mysql.user;\"\nEnter password: \n+------------------+\n| User             |\n+------------------+\n| root             |\n| mysql.infoschema |\n| mysql.session    |\n| mysql.sys        |\n| rdsadmin         |\n+------------------+\n\n```\n\n## Debugging mode\n\nIf you run into issues, you can get detailed debug log by setting **GATE_DEBUG** environment variable:\n```\nexport GATE_DEBUG=1\n```\n\nAfter setting the environment variable, the debug mode will be automatically enabled:\n```\n% aws-gate session test\n2019-05-26 01:18:23,535 - aws_gate.config  - DEBUG - Located config file: /Users/xenol/.aws-gate/config\n2019-05-26 01:18:23,538 - aws_gate.utils   - DEBUG - Obtaining boto3 session object\n2019-05-26 01:18:23,549 - aws_gate.utils   - DEBUG - Obtained configured AWS profiles: default development preproduction production\n2019-05-26 01:18:23,550 - aws_gate.utils   - DEBUG - Obtaining boto3 session object\n2019-05-26 01:18:23,560 - aws_gate.utils   - DEBUG - Obtained configured AWS profiles: default development preproduction production\n2019-05-26 01:18:23,560 - aws_gate.utils   - DEBUG - Obtaining boto3 session object\n2019-05-26 01:18:23,574 - aws_gate.utils   - DEBUG - Obtaining ssm client\n2019-05-26 01:18:23,608 - aws_gate.utils   - DEBUG - Obtaining boto3 session object\n2019-05-26 01:18:23,636 - aws_gate.utils   - DEBUG - Obtaining ec2 boto3 resource\n2019-05-26 01:18:23,694 - aws_gate.query   - DEBUG - Querying EC2 API for instance identifier: SSM-test\n2019-05-26 01:18:24,029 - aws_gate.query   - DEBUG - Found 1 maching instances\n2019-05-26 01:18:24,030 - aws_gate.query   - DEBUG - Matching instance: i-0772e4c1dcdd763b6\n2019-05-26 01:18:24,030 - aws_gate.session - INFO  - Opening session on instance i-0772e4c1dcdd763b6 (eu-west-1) via profile default\n2019-05-26 01:18:24,030 - aws_gate.session - DEBUG - Creating a new session on instance: i-0772e4c1dcdd763b6 (eu-west-1)\n...\n```\n\nDebug mode also enables printing of Python stack traces if there is a crash or some other problem.\n\n## License\n\nThis project is licensed under the BSD License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/xen0l/aws-gate.svg)](https://starchart.cc/xen0l/aws-gate)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxen0l%2Faws-gate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxen0l%2Faws-gate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxen0l%2Faws-gate/lists"}