SSH client wrapper for easily connecting to hosts
Project description
ssht
SSH client wrapper for easily connecting to hosts
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:
- 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'),
]
- Enable your class in
~/.ssht/config.json
{
"parsers":
[
"ssht.plugins.JsonParser",
"ssht_provider.ExampleParser"
]
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ssht-1.0.2.tar.gz
.
File metadata
- Download URL: ssht-1.0.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65681af31c62e0737d185ec486aca431ec021337aa30a261065a5eebbf919845 |
|
MD5 | 88ca624370a46ff725f172e5914a5c20 |
|
BLAKE2b-256 | 9f40cbe6885f993a64c7296145aae567eabe893ef0e1c493b9fe94d937a9fb0e |
File details
Details for the file ssht-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: ssht-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca4ac58d7504a6ae4e9500a8622adc84b8299ddede4b50c234b43b175239dd9 |
|
MD5 | fc99db217b9abe5329a88d85bd96de54 |
|
BLAKE2b-256 | f5d37442652e6661e667ff35ab13a89b2acf8ef23accb8259fcfe18fc0e5b753 |