From 25be46c176016d06522ae5db1bbb64d38e428864 Mon Sep 17 00:00:00 2001 From: zlaxy Date: Sat, 15 Jul 2017 18:11:06 +0300 Subject: [PATCH] Initial --- README.md | 3 +++ sshch.py | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 README.md create mode 100644 sshch.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..9697a10 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +Simpe python script for fast access to ssh hosts. + +under DWTWL 2.5 license: https://soundragon.su/license/license.html diff --git a/sshch.py b/sshch.py new file mode 100644 index 0000000..4f0e5d9 --- /dev/null +++ b/sshch.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from os import path +from sys import argv +import ConfigParser +import subprocess +import base64 + +conf_file = path.expanduser("~") + '/.config/sshch.conf' + +conf = ConfigParser.RawConfigParser() +if not path.exists(conf_file): + open(conf_file, 'w') +conf.read(conf_file) +if conf.has_section(argv[-1]): + exec_string = "" + if conf.has_option(argv[-1], "pass"): + password = base64.b64decode(conf.get(argv[-1], "pass")) + exec_string = "sshpass -p " + password + " " + exec_string = exec_string + conf.get(argv[-1], "exec_string") + p = subprocess.Popen(exec_string, shell=True, stderr=subprocess.PIPE, ) + streamdata = p.communicate()[0] +else: + print "There is no '" + argv[-1] + "' section in config file"