Skip to main content

Generate 'ssh_config' files, based on current Amazon EC2 state.

Project description

# SSH config synchronisation for AWS

Generate ssh_config files, based on current [Amazon EC2](https://aws.amazon.com/ec2/) state.

## Features

  • Connect to one or more regions at once.

  • Filter EC2 instances by name. Useful for including relevant nodes only or for creating separate config sets for the same environment (e.g. use a different User for different nodes).

  • Identify hosts using tags or instance IDs:
    • Index duplicates (e.g. in autoscaling groups) using instance launch time.

    • Include a global name prefix and/or a region ID to identify the connection in a unique way.

  • Use public or private IPs.

  • Set various SSH params:
    • Skip strict host checking, if needed. Can be useful when working with (internal) autoscaling groups.

    • Provide a server alive interval to keep the connection from timing out.

    • Use custom identity files.

  • Write to stdout or a [master file with config-key substitution](#file-output). Useful for working with tools, that don’t support the Include directive.

## Usage

Using a virtual [pipenv](https://github.com/pypa/pipenv) environment is recommended, but not strictly required. If you have all [dependencies](Pipfile) present, you can launch the script directly.

To start the virtual environment: ` pipenv shell `

To get the full list of options: `bash ./aws_ssh_sync.py --help `

### Preview

The easiest way to get a preview of the current config in AWS is to print the output directly to stdout:

`bash ./aws_ssh_sync.py --profile <profile> --region <region> `

### Utilising the ‘Include’ directive

If you want to isolate the generated config, you can write it to a dedicated file, and Include it in the main config. The base use-case is as follows:

`bash ./aws_ssh_sync.py --profile <profile> --region <region> > ~/.ssh/config.d/<some_file> `

To extend your ~/.ssh/config, add the following line:

` Include config.d/* `

### <a name=”file-output”></a>Working with a single config file

Splitting config into multiple, small files keeps things elegant and clean - you should probably stick to that, if you can.

Unfortunatelly, some tools may still have trouble with the Include directive itself. If you want to use a single file (e.g. ~/.ssh/config) for keeping all configuration, then you can specify the –output-file together with a –config-key:

`bash ./aws_ssh_sync.py --profile <profile> --region <region> --config-key <key> --output-file <path> `

Behaviour:

  • Configuration is written to the –output-file rather than stdout.

  • If the file doesn’t exist, then it will be created.

  • If a section identified by –config-key exists, then it will be replaced.

  • If no –config-key was found, then a new section will be appended to the file.

  • No backup file is created at the moment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-ssh-sync-0.0.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_ssh_sync-0.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file aws-ssh-sync-0.0.1.tar.gz.

File metadata

  • Download URL: aws-ssh-sync-0.0.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for aws-ssh-sync-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4f443b5715a47843e91e2592a20b6bd947a83ae23007b7bdffb372717e095c75
MD5 538e67d0553f5550e3c3e0184f5bcd79
BLAKE2b-256 5ee30a5ddd50f20121aad7486d6682f6742e23d6d0fd9c264898f1fb2312b52c

See more details on using hashes here.

File details

Details for the file aws_ssh_sync-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_ssh_sync-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa696324c8a54cf7ad90ee6518e399babf75f78569ff4a6def99eede8f2e7505
MD5 3d1ce200d31a266caffd12609bd8b2aa
BLAKE2b-256 c86ae6b67c776f16d01cfbb79f832341e64e107aac1f1671a578321cb07d2bbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page