This commit is contained in:
ivan 2017-07-15 18:11:06 +03:00
commit 25be46c176
2 changed files with 28 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
Simpe python script for fast access to ssh hosts.
under DWTWL 2.5 license: https://soundragon.su/license/license.html

25
sshch.py Normal file
View File

@ -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"