{ "info": { "author": "Huan Xiong", "author_email": "huan.xiong@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: System Administrators", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "A simple SSH host manager in terminal.\n\n# Introduction\n\nPickhost allows you to define SSH login information (e.g., host, user, comments, etc.) in an simple INI style config file and select a host in an interactive way in terminal. It's implemented using PyPick.\n\nCompared to existing SSH managers (as far as I know, all of them are GUI applications), pickhost is simple to config and quick to launch. It's non-disruptive and integrates with your workflow well if you spend most of your time in terminal.\n\nThe following is an example screenshot:\n\n![docs/images/demo.png](docs/images/demo.png)\n\n# Install\n\nAs Python2 will be EOL'ed soon, PyPick supports only Python3. To install it, run:\n\n $ python3 -m pip install pickhost\n\n# A Quick-Start Guide\n\n## A Simple Example\n\nTo use pickhost, you need to add your hosts to its config file. The config file is located at $HOME/.config/pickhost/hosts by default. Or you can specify a custom config file using -f option if you like. Config file is of INI format. You can edit it with any editor you like. Pickhost provides a convenient option -e, which opens the file using editor specified by EDITOR environment variable or vi if it's not set.\n\n $ pickhost -e\n\t\nAdd the following to the file:\n\n [ARM servers]\n server-5 = rayx@10.64.4.5 #centos 7.4\n server-66 = root@10.64.4.66 #ubuntu 16.04\n \n [Benchmarking]\n arm-server = rayx,root@10.64.37.55 #Centriq 2400, 192G RAM\n x86-server = rayx,root@10.64.37.51 #Xeon Gold 5118, 192G RAM\n test-client = rayx,root@10.64.37.182\n\nThe file contains multiple sections. This is not mandatory and you can add hosts to the file without using section. That said, it's recommended to group your hosts in sections because it helps to identify your host quickly.\n\nExcept section header, each line in the file describes a host in this format:\n\n = @ #\n\n- 'name' is a string you'd like to call the host. It mustn't have any of these characters: '=', '@', '#'.\n- 'users' is a comma separated list. The first value in the list is displayed by default. You can go through other availale values by pressing 'u'.\n- 'host' is the host to be ssh'ed into. It can be any valid hostname accepted by SSH client on your machine. For example, it can be IP address, short hostname, FQDN, or a hostname translated by SSH client (see 'HostName' option in ssh_config(5) man page).\n- 'comment' is an arbitrary string. It provides additional information about the host, like what project it's used for, its configuration, etc.\n\nThe above configuration generates a list like the following. Note that there is a small triangle '\u25be' after user name in some entries. That indicates there are multiple available user name values and you can press 'u' to go through them.\n\n![docs/images/simple_example.png](docs/images/simple_example.png)\n\nYou can press 'UP' and 'DOWN' (or VI style 'j' and 'k') to navigate through items in the list, press 'ENTER' (or 'SPACE') to select an entry, or press 'ESC' (or 'q') to quit without selecting anyting. \n\nNow suppose you navigate to the first entry in 'Benchmarking' section. Press 'u' once to change user name from 'rayx' to 'root', then press 'ENTER'. Pickhost would print the following on stderr:\n\n $ pickhost\n export PH_USER=root\n export PH_HOST=10.64.37.55\n export PH_NAME=arm-server\n\nThat's pretty much it for this section. Next we'll talk about how to use the above output in shell script and a few more useful features of pickhost.\n\n## Processing Pickhost Output in Shell Script\n\nPickhost command output is expected to be consumed by shell script. Below is an example code on how to do that:\n\n function pick {\n unset PH_NAME PH_USER PH_HOST\n eval $(pickhost 2>&1 >/dev/tty)\n # Return if no entry is selected.\n [[ -n $PH_NAME ]] || return 0\n echo \"Logging into ${PH_NAME}...\"\n ssh ${PH_USER}@${PH_HOST}\n }\n\nIf you want to use pickhost in your Python program, you can instantiate the PickHost class in pickhost module. That is out of the scope of this tutorial, so please refer to the code.\n\n## Last Accessed Host\n\nNow you have run pickhost for the first time and selected an entry. If you try it again, the list changes a bit:\n\n![docs/images/last_accessed_entry.png](docs/images/last_accessed_entry.png)\n\nNote there is a 'last accessed' entry at the top of the list, which contains the entry you selected last time. You just need to press 'ENTER' to start a new login session. This is useful feature to save a lot of key press in a busy work day.\n\n## Parent/Child Relationship among Hosts\n\nYou can define parent/child relationship between hosts. This is particularly useful when you need to deal with VMs in your work. Below is an example config file:\n\n [ARM servers]\n server-5 = rayx@10.64.4.5 #centos 7.4\n server-5->vm-176 = root,rayx@192.168.122.176 #qemu: hotplugging\n server-5->vm-176->nested-vm = root,rayx@191.168.56.18 #nested-vm\n server-5->vm-37 = root,rayx@192.168.122.37 #qemu: virtio-block\n server-66 = root@10.64.4.66 #ubuntu 16.04\n \n [Benchmarking]\n arm-server = rayx,root@10.64.37.55 #Centriq 2400, 192G RAM\n x86-server = rayx,root@10.64.37.51 #Xeon Gold 5118, 192G RAM\n test-client = rayx,root@10.64.37.182\n\t\nAs you may notice, a child host's name containing all its ancestor names, separated by '->'. The config file generates a list like the following, which shows the relationship visually and helps you to identify a VM quickly.\n\n![docs/images/parent_and_child.png](docs/images/parent_and_child.png)\n\nYou don't need to keep the entrys in correct order. For example, the config file below generates the same list:\n\n [ARM servers]\n server-5 = rayx@10.64.4.5 #centos 7.4\n server-66 = root@10.64.4.66 #ubuntu 16.04\n server-5->vm-176 = root,rayx@192.168.122.176 #qemu: hotplugging\n server-5->vm-37 = root,rayx@192.168.122.37 #qemu: virtio-block\n server-5->vm-176->nested-vm = root,rayx@191.168.56.18 #nested-vm\n \n [Benchmarking]\n arm-server = rayx,root@10.64.37.55 #Centriq 2400, 192G RAM\n x86-server = rayx,root@10.64.37.51 #Xeon Gold 5118, 192G RAM\n test-client = rayx,root@10.64.37.182\n\n## Highlighting a Host\n\nAmong all hosts in a list, there are usually a few ones which you access frequently. For those hosts, you may want to highlight them so that you can quickly identify them. This is particularly useful if you have a long list.\n\nYou can highlight an entry by adding '!' character after the host name. Below is an example:\n\n [ARM servers]\n server-5 = rayx@10.64.4.5 #centos 7.4\n server-5->vm-176! = root,rayx@192.168.122.176 #qemu: hotplugging\n server-5->vm-176->nested-vm = root,rayx@191.168.56.18 #nested-vm\n server-5->vm-37 = root,rayx@192.168.122.37 #qemu: virtio-block\n server-66 = root@10.64.4.66 #ubuntu 16.04\n \n [Benchmarking]\n arm-server! = rayx,root@10.64.37.55 #Centriq 2400, 192G RAM\n x86-server = rayx,root@10.64.37.51 #Xeon Gold 5118, 192G RAM\n test-client = rayx,root@10.64.37.182\n\t\nIt generates a list like this:\n\n![docs/images/highlighting.png](docs/images/highlighting.png)\n\n# Manual\n\n $ pickhost -h\n usage: pickhost [-h] [-f file] [-e]\n \n optional arguments:\n -h, --help show this help message and exit\n -f file config file\n -e edit config file rather than show it\n\n# TODO\n\n- Allow user to set theme (e.g., width and color of the columns)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rayx/pickhost", "keywords": "", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "pickhost", "package_url": "https://pypi.org/project/pickhost/", "platform": "unix-like", "project_url": "https://pypi.org/project/pickhost/", "project_urls": { "Homepage": "https://github.com/rayx/pickhost" }, "release_url": "https://pypi.org/project/pickhost/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "A simple SSH host manager in terminal", "version": "0.1.1" }, "last_serial": 5176275, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "1c31bc553c398cf9f02164668ca3ce23", "sha256": "46ecb33ce408e295d21644ba05b4ce0cddd23b7a8e17e6e81d03efc1a31f18e8" }, "downloads": -1, "filename": "pickhost-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1c31bc553c398cf9f02164668ca3ce23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 381172, "upload_time": "2019-04-23T09:19:03", "url": "https://files.pythonhosted.org/packages/18/a5/9b776d6083d1382e5c218ecdf9c5723b6180883e1f55ad74009b45d26fcd/pickhost-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c31bc553c398cf9f02164668ca3ce23", "sha256": "46ecb33ce408e295d21644ba05b4ce0cddd23b7a8e17e6e81d03efc1a31f18e8" }, "downloads": -1, "filename": "pickhost-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1c31bc553c398cf9f02164668ca3ce23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 381172, "upload_time": "2019-04-23T09:19:03", "url": "https://files.pythonhosted.org/packages/18/a5/9b776d6083d1382e5c218ecdf9c5723b6180883e1f55ad74009b45d26fcd/pickhost-0.1.1.tar.gz" } ] }