Skip to main content

ssh client config manager

Project description

SSH Config

PyPI version Build Status

SSH client config file manager

What is ssh_config?

https://linux.die.net/man/5/ssh_config

Why

I don't remember all the servers I am managing. Also all servers require all different configurations to connect to it. I know ~.ssh/config can handle this kind of issue. I want it to handle this file easier.

Yes, I am not sure this is easier way to handle it. but I am trying.

Requirements

After 0.0.15, Python27 is not supported.

Python 3.6 or higher

Installation

$ pip install ssh-config

Usage

ssh-config <version>

   Usage:
       ssh-config [options] <command> [<args>...]

   Options:
       -h --help           Show this screen.
       -v --version        Show version.
       -V --verbose        Verbose output
       -f --config FILE    Specify an ssh client file [default: ~/.ssh/config]

   Commands:
       gen         Generate ssh config file
       ls          Show list of Hosts in client file
       get         Get ssh client config with Name
       add         Add new Host configuration
       update      Update host configuration
       rename      Update host configuration
       rm          Remove exist Host configuration
       import      Import Hosts from csv file to SSH Client config
       export      Export Hosts to csv/ansible format
       bastion     Bastion register/use
       ping        Send ping to selected host
       version     Show version information

Use-cases

List hosts

$ ssh-config ls
# It shows name and HostName attribute
server1: 203.0.113.76
*: None
server_cmd_1: 203.0.113.76
server_cmd_2: 203.0.113.76
server_cmd_3: 203.0.113.76
Add host
$ ssh-config add "server_cmd_4" HostName=203.0.113.77 IdentityFile="~/.ssh/cmd_id_rsa"
Update host
$ ssh-config add --update -p "server_cmd_3" IdentityFile="~/.ssh/cmd_id_rsa"
Remove host
$ ssh-config rm "server_3"

Using pattern to get list or update exist hosts

List hosts with pattern
$ ssh-config ls "server_*"
# It shows name and HostName attribute
server_cmd_1: 203.0.113.76
server_cmd_2: 203.0.113.76
server_cmd_3: 203.0.113.76
Update hosts with pattern
$ ssh-config add --update -p "server_*" IdentityFile="~/.ssh/cmd_id_rsa"

add ssh key to multiple servers

ssh-config ls --only-name | xargs -I{} ssh-copy-id -i ~/.ssh/id_rsa {}

Export ssh-config to ansible inventory ini format.

ssh-config export ansible -g linux

[linux]
server1              ansible_host=203.0.113.76       
server_cmd_1         ansible_host=203.0.113.76       
server_cmd_2         ansible_host=203.0.113.76         ansible_user=user     
server_cmd_3         ansible_host=203.0.113.76         ansible_user=user     

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

ssh_config-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

ssh_config-0.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file ssh_config-0.1.0.tar.gz.

File metadata

  • Download URL: ssh_config-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for ssh_config-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4822722759e0f488448d86561cc5e27972bf126337233df097017cf08349851
MD5 329c5988fe795e6c16cba0e550cda1a1
BLAKE2b-256 5382601887a33e71edfb8e329d8abe88612ef0a23e364fd8414467f52e3ced7f

See more details on using hashes here.

Provenance

File details

Details for the file ssh_config-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ssh_config-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for ssh_config-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e87ba21567c87483d94b2dc55d75d016106ed1d8d1104beae15d9a8beffb84e6
MD5 c2462fcad47892e0b720be2a74d9ef9b
BLAKE2b-256 469ca133bc7751d9499ff26e18b1064726e94dd88330698b3f9c13d198eab30a

See more details on using hashes here.

Provenance

Supported by

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