From 5c97202d0b14976163317e15e0a37f7aa0c7ff3c Mon Sep 17 00:00:00 2001 From: Jake Zaia Date: Fri, 12 Oct 2018 17:26:58 -0400 Subject: [PATCH] Add creation function --- src/config_manager.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/config_manager.py diff --git a/src/config_manager.py b/src/config_manager.py new file mode 100644 index 0000000..5abe86c --- /dev/null +++ b/src/config_manager.py @@ -0,0 +1,27 @@ +#This file manages SSH config files + +SSH_CONFIG_FILE_LOC = 'config' + +def create_config(): + print("Please input the relevent information for generating your config file.") + host = input("Nickname for Host: ") + hostname = input("Hostname: ") + user = input("Username: ") + port = input("Would you like to specify a port?(y/N)") + if (port == 'y' or port == 'Y' or port.lower() =='yes'): + port = input("Port number: ") + else: + port = None + identityfile = input("Would you like to specify an ssh key location?(y/N)") + if (identityfile == 'y' or identityfile == 'Y' or identityfile.lower() =='yes'): + identityfile = input("SSH Public key file location: ") + f = open(SSH_CONFIG_FILE_LOC, 'w') + f.write("Host {0}\n".format(host)) + f.write("\tHostName {0}\n".format(hostname)) + f.write("\tUser {0}\n".format(user)) + if port: + f.write("\tPort {0}\n".format(port)) + if identityfile: + f.write("\tIdentityFile {0}\n".format(identityfile)) + +create_config() \ No newline at end of file