Skip to main content

SSH client wrapper for easily connecting to hosts

Project description

ssht

SSH client wrapper for easily connecting to hosts

Coverage Status

This wrapper for the well known ssh client makes it possible to connect to the right server with just typing a part of the host name. The external sources are queried using the search term and those matching the string will be presented as an option.

Current supported sources:

  • JSON file
  • MySQL database
  • JSON API endpoint
  • Custom parser class

Installation

Install ssht using pip:

pip3 install ssht

or if you want the latest version:

pip3 install https://github.com/hkraal/ssht/archive/master.zip

Usage

ssht [-h] name [-4] [-6]

positional arguments:
  name        name of the host to connect to

optional arguments:
  -h, --help  show this help message and exit
  -4          connect using ipv4 (skip dns if ipv4 address is defined)
  -6          connect using ipv6 (skip dns of ipv6 address is defined)

Example of a connection

$ ssht host01
1) root@host01.exmaple.com
2) host01.exmaple.com
Connect to: 1
Connecting to "host01.example.com"
root@host01:~$

Configuration

Create ssht folder in home directory

mkdir ~/.ssht

Configure sources in ~/.ssht:

Define servers in JSON format:

{
	"hosts": [
	  {
		"port": "2222",
		"hostname": "host01.example.com",
		"ipv4": "192.168.0.2",
		"user": "root"
	  },
	  {
		"port": "2222",
		"hostname": "host01.example.com",
		"ipv4": "192.168.0.2",
	  }
	]
}

Define servers in MySQL:

{
  "config": {
    "host": "localhost",
    "user": "username",
    "password": "passeword",
    "database": "infra"
  },
  "query": "SELECT hostname, port, ipv4, ipv6, user FROM servers"
}

Define JSON API endpoint:

{
	"config": {
		"url": "http://ssht-api.dev",
		"headers": {
			"Authentication": "bla:huk"
		}
	}
}

Define custom class:

  1. Create a Python package containing your class
from ssht.plugins import Parser, Host


class ExampleParser(Parser):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._files = self.get_files('.custom')

    def search(self, needle):
        return [
            Host(hostname='host01.example.com', ipv4='192.168.0.2'),
        ]
  1. Enable your class in ~/.ssht/config.json
{
    "parsers":
    [
        "ssht.plugins.JsonParser",
        "ssht_provider.ExampleParser"
    ]
}

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

ssht-3.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

ssht-3.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ssht-3.0.1.tar.gz.

File metadata

  • Download URL: ssht-3.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.10 Darwin/25.3.0

File hashes

Hashes for ssht-3.0.1.tar.gz
Algorithm Hash digest
SHA256 1b6977c867973731364e36aac8df12c69db0410428c5547ad25d9b103f272bd1
MD5 113d2f3e01ad7239ba074f744c2323be
BLAKE2b-256 4bc8d96609cc36e7e33130ef1f8cad5622fdb03ddd240892f179c89a9573b1b3

See more details on using hashes here.

File details

Details for the file ssht-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: ssht-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.10 Darwin/25.3.0

File hashes

Hashes for ssht-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78fd4a2661cb884beb96af9819c15a05351428533f64babcd9bad60bf8629192
MD5 d991b99b7f060996b7a19a533208e697
BLAKE2b-256 1f7260b24a157952734b4de8e7b55851417cc0643e4f132b95743abe9bf9fb0e

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