import sys import subprocess import os, errno import myssl # SSH to AWS using putty and a key # The key file is encrypted so unlock this file then ssh then lock key file again putty = "C:\\Users\\User\\Desktop\\Work\putty.exe" print("\tPress ENTER for defaults") profile = input('\tEnter the putty profile you want to use [AWSWebServer]: ') if len(profile) == 0: profile = 'AWSWebServer' keyfile = input('\tEnter the key file name to use [awscert]:') if len(keyfile) == 0: keyfile = 'awscert' password = "******" #Unlock key file .lck and keep password for encryption password = myssl.unlock(keyfile) #SSH to AWS using Putty profile command = "%s -load %s" % (putty, profile) p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) #output, error = p.communicate() #Lock the key file .ppk myssl.lock(keyfile, password) exit(0)
#!c:/Python34/python.exe -u import sys import myssl # Check arguments if (len(sys.argv) != 3) or (sys.argv[1] != "-l" and sys.argv[1] != "-u"): print("Usage: " + sys.argv[0] + " -[l|u] filename") exit(1) # Run unlock or lock filename = sys.argv[2] if sys.argv[1] == "-l": myssl.lock(filename, "") elif sys.argv[1] == "-u": myssl.unlock(filename) else: print("We should not be here")