Skip to main content

SSH Config and Ansible Inventory Generator.

Project description

ssh-config-ansible-inventory-generator

This tool should help you manage ssh config file with hosts as well as ansible hosts or inventory file.

Structure

  1. Insert host information to a JSON file as a DB.
  2. Generate SSH Config file and an Ansible Inventory file.

Install

% pip3 install sshc

Usage

Step 1: Need the DB to be initiated for the first time

% sshc init

Step 2: Insert host information to the Database

% sshc insert --name Google --host 8.8.8.8 --port 22 --user groot --identityfile /home/fahad/fahad.pem --comment "This is the server where you are not authorized to have access." --configfile /home/fahad/.ssh/config --groups google, fun

Step 3: Generate ssh config and as well as ansible inventory file

% python3 sshc.py generate

This command will read all the entries in the DB and generate

  1. SSH config file in your preferred directory or default one(i.e. $HOME/.ssh/config).
  2. Ansible Inventory file will be created at your preferred directory or in default one.

If you do not change default directory, then you will be able to use the SSH configs immediately. But Ansible inventory will not be created in its default directory. You need to choose the inventory file or create link file.

For SSH,

% ssh -F <DIR>/config

For Ansible,

% ansible -i <DIR>/hosts.json all --list-host

Others

Help message of the tool

% sshc --help
usage: sshc [-h] [--version] [--destination DESTINATION] [--identityfile IDENTITYFILE] [--configfile CONFIGFILE] [--dbfile DBFILE] [--inventoryfile INVENTORYFILE]
            {init,insert,delete,read,generate} ...

SSH Config and Ansible Inventory Generator !

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --destination DESTINATION
                        Config HOME?
  --identityfile IDENTITYFILE
                        SSH Default Identity File Location. i.e. id_rsa
  --configfile CONFIGFILE
                        SSH Config File.
  --dbfile DBFILE       SSHC DB File.
  --inventoryfile INVENTORYFILE
                        Ansible Inventory File.

subcommands:
  The main command of this CLI tool.

  {init,insert,delete,read,generate}
                        The main commands have their own arguments.
    init                Initiate Host DB !
    insert              Insert host information !
    delete              Delete host information !
    read                Read Database !
    generate            Generate necessary config files !

Delete Inserted Data

% sshc delete --hostname <HOSTNAME>

Read DB Data

sshc read

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

sshc-0.3.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

sshc-0.3.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file sshc-0.3.0.tar.gz.

File metadata

  • Download URL: sshc-0.3.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.0.12-76060006-generic

File hashes

Hashes for sshc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1a3e19f0479c5f3311398691b5d619f598beafd6f7ca3769638e66ab4c3d64b6
MD5 9a52874dd47632af024c7352860aa0a2
BLAKE2b-256 76fa09c3626993f6c4a5869ebe66554386c5f56ff8e73760422ff13228ff9a59

See more details on using hashes here.

File details

Details for the file sshc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sshc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.0.12-76060006-generic

File hashes

Hashes for sshc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f31af08450edda94dcc9544b0cd15b8f30b67729bac3d74ae199743573d6af8
MD5 a295ce63cd73e531ea9ff62bc9ebf40d
BLAKE2b-256 7cefa71577c9b905f9ce4766a02cf934398a101b948be84ba4ef49abdc70d8c9

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