{"id":13499345,"url":"https://github.com/mirakui/ec2ssh","last_synced_at":"2025-05-16T15:08:07.963Z","repository":{"id":1220602,"uuid":"1138161","full_name":"mirakui/ec2ssh","owner":"mirakui","description":"A ssh_config manager for AWS EC2","archived":false,"fork":false,"pushed_at":"2023-12-25T09:24:42.000Z","size":215,"stargazers_count":252,"open_issues_count":1,"forks_count":37,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-27T10:46:31.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/mirakui.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2010-12-04T15:22:13.000Z","updated_at":"2025-04-01T11:45:06.000Z","dependencies_parsed_at":"2024-01-02T21:57:52.360Z","dependency_job_id":"b31e2c68-b204-4bda-a007-d62f61953641","html_url":"https://github.com/mirakui/ec2ssh","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirakui%2Fec2ssh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirakui%2Fec2ssh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirakui%2Fec2ssh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirakui%2Fec2ssh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirakui","download_url":"https://codeload.github.com/mirakui/ec2ssh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010810,"owners_count":21998993,"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":[],"created_at":"2024-07-31T22:00:32.347Z","updated_at":"2025-05-16T15:08:02.947Z","avatar_url":"https://github.com/mirakui.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/ec2ssh.svg)](https://badge.fury.io/rb/ec2ssh)\n[![Build Status](https://github.com/mirakui/ec2ssh/actions/workflows/main.yml/badge.svg)](https://github.com/mirakui/ec2ssh/actions/workflows/main.yml)\n\n# Introduction\nec2ssh is a ssh_config manager for Amazon EC2.\n\n`ec2ssh` command adds `Host` descriptions to ssh_config (~/.ssh/config default). 'Name' tag of instances are used as `Host` descriptions.\n\n# How to use\n### 1. Set 'Name' tag to your instances\neg. Tag 'app-server-1' as 'Name' to an instance i-xxxxx in us-west-1 region.\n\n### 2. Write ~/.aws/credentials\n```\n# ~/.aws/credentials\n\n[default]\naws_access_key_id=...\naws_secret_access_key=...\n\n[myprofile]\naws_access_key_id=...\naws_secret_access_key=...\n```\n\nIf you need more details about `~/.aws/credentials`, check [A New and Standardized Way to Manage Credentials in the AWS SDKs](http://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs)\n\n### 3. Install ec2ssh\n\n```\n$ gem install ec2ssh\n```\n\n### 4. Execute `ec2ssh init`\n\n```\n$ ec2ssh init\n```\n\n### 5. Edit `.ec2ssh`\n\n```\n$ vi ~/.ec2ssh\n---\nprofiles 'default', 'myprofile', ...\nregions 'us-east-1', 'ap-northeast-1', ...\n\n# Ignore unnamed instances\nreject {|instance| !instance.tag('Name') }\n\n# You can specify filters on DescribeInstances (default: lists 'running' instances only)\nfilters([\n  { name: 'instance-state-name', values: ['running', 'stopped'] }\n])\n\n# You can use methods of AWS::EC2::Instance and tag(key) method.\n# See https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/EC2/Instance.html\nhost_line \u003c\u003cEND\nHost \u003c%= tag('Name') %\u003e.\u003c%= placement.availability_zone %\u003e\n  HostName \u003c%= public_dns_name || private_ip_address %\u003e\nEND\n```\n\n### 6. Execute `ec2ssh update`\n\n```\n$ ec2ssh update\n```\nThen host-names of your instances are generated and wrote to .ssh/config\n\n### 7. And you can ssh to your instances with your tagged name.\n\n```\n$ ssh app-server-1.us-east-1a\n```\n\n# Commands\n```\n$ ec2ssh help [TASK]  # Describe available tasks or one specific task\n$ ec2ssh init         # Add ec2ssh mark to ssh_config\n$ ec2ssh update       # Update ec2 hosts list in ssh_config\n$ ec2ssh remove       # Remove ec2ssh mark from ssh_config\n```\n\n## Options\n### --dotfile\nEach command can use `--dotfile` option to set dotfile (.ec2ssh) path. `~/.ec2ssh` is default.\n\n```\n$ ec2ssh init --dotfile /path/to/ssh_config\n```\n\n# ssh_config and mark lines\n`ec2ssh init` command inserts mark lines your `.ssh/config` such as:\n\n```\n### EC2SSH BEGIN ###\n# Generated by ec2ssh http://github.com/mirakui/ec2ssh\n# DO NOT edit this block!\n# Updated Sun Dec 05 00:00:14 +0900 2010\n### EC2SSH END ###\n```\n\n`ec2ssh update` command inserts 'Host' descriptions between 'BEGIN' line and 'END' line.\n\n```\n### EC2SSH BEGIN ###\n# Generated by ec2ssh http://github.com/mirakui/ec2ssh\n# DO NOT edit this block!\n# Updated Sun Dec 05 00:00:14 +0900 2010\n\n# section: default\nHost app-server-1.us-west-1\n  HostName ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com\nHost db-server-1.ap-southeast-1\n  HostName ec2-xxx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com\n    :\n    :\n### EC2SSH END ###\n```\n\n`ec2ssh remove` command removes the mark lines.\n\n# How to upgrade from 3.x\nDotfile (`.ec2ssh`) format has been changed from 3.x.\n\n* A instance tag access I/F has been changed from `tags['Name']` to `tag('Name')`\n* `Aws::EC2::Instance` methods have been changed to AWS SDK v3\n* The `aws_keys` structure has been changed\n  * `aws_keys[profile_name][region] # =\u003e Aws::Credentials`\n  * For example:\n\n```\naws_keys(\n  my_prof1: {\n    'ap-northeast-1' =\u003e Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])\n  }\n)\n```\n\n# Notice\n`ec2ssh` command updates your `.ssh/config` file default. You should make a backup of it.\n\n# Zsh completion support\nUse `zsh/_ec2ssh`.\n\n# License\nCopyright (c) 2022 Issei Naruta. ec2ssh is released under the MIT license.\n","funding_links":[],"categories":["Ruby","Apps","Open Source Repos"],"sub_categories":["`.ssh/config`","Elastic Compute Cloud"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirakui%2Fec2ssh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirakui%2Fec2ssh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirakui%2Fec2ssh/lists"}