コード例 #1
0
def remove_drive():
    """
    Prompts the user and removes a drive from MOUNT_FILE
    """
    options = []
    file = module.input_file(MOUNT_FILE)
    for i in range(0, len(file), 3):
        options.append(str(len(options) + 1) + ") " + file[i])
    
    options.append("A) Exit")

    module.print_menu("Remove SSH Drive", options)

    i = input("Enter Option:")

    if i.lower() != 'a' and int(i) <= len(file)/3 and int(i) > 0:
        index = (int(i) - 1) * 3

        f = open(MOUNT_FILE, "w")
        for x in range(0, len(file), 3):
            if index != x:
                f.write(file[x] + "\n")
                f.write(file[x + 1] + "\n")
                f.write(file[x + 2] + "\n")
        f.close()
コード例 #2
0
ファイル: configuration.py プロジェクト: zethra/bash_manager
def main():
    """
    Prompts user to either update the config file, or make aliases
    in the bash configuration
    """

    options = []
    options.append("1) Update Configuration File")
    options.append("2) Make Aliases")
    options.append("3) Add Extra Sauce")
    options.append("4) View proposed shell conf")
    options.append("5) Exit")
    i = '0'

    while i != '5':
        module.print_menu("Configuration Manager", options)
        i = input("Enter Option:")
        if i == '1':
            create_config()
        elif i == '2':
            write_to_bash_config(generate_bash_aliases())
        elif i == '3':
            write_to_bash_config(generate_extra_sauce())
        elif i == '4':
            view_shell_sauce()
コード例 #3
0
ファイル: ssh_manager.py プロジェクト: zethra/bash_manager
def socks_ssh_tunnel():
    """
    prints user a menu to select a host to start a socks proxy with
    :return: None
    """
    file = module.input_file(INPUT_FILE)
    cmp = []
    count = 1
    for line in file:
        cmp.append(Computer(line, count))
        count += 1

    menu = []
    for c in cmp:
        menu.append(str(c.menu_id) + ") " + c.host)

    menu.append("A) Exit")
    menu.append("B) Main")
    module.print_menu("Socks Tunnel", menu)

    i = input("Enter option:")
    if i == '' or 'a' == str.lower(i):
        exit_program()
    elif 'b' == str.lower(i):
        main()
    else:
        for c in cmp:
            if int(i) == c.menu_id:
                print_red("Starting socks proxy on " + c.host + ":8123")
                subprocess.call(
                    ["ssh", "-D", "8123", "-C", "-q", "-N", c.host])
                exit_program()
コード例 #4
0
ファイル: ssh_manager.py プロジェクト: zethra/bash_manager
def print_sub_menu():
    """
    prints out a sub help menu for other options
    :return: None
    """
    module.print_menu("Options", [
        "1) Add Host", "2) Copy SSH key to server", "3) Remove host name",
        "4) Return to ssh manager", "5) Manage Configuration and Bash",
        "6) Exit"
    ])
コード例 #5
0
def print_mount_menu():
    """
    Displays box which has mount menu options
    """
    module.print_menu("SSH Drive Manager", [
        "1) Mount SSH Drives", "2) Un-Mount SSH Drives",
        "3) Remove Remote Drive", "4) Add Drive to Mount", "5) View Drives",
        "6) Usage", "7) Manage Config", "8) Forcefully Un-Mount SSH Drives",
        "9) Exit"
    ])
コード例 #6
0
def print_sub_menu():
    """
    prints out a sub help menu for other options
    :return: None
    """
    module.print_menu("Options", ["1) Add Host",
                                  "2) Remove host name",
                                  "3) Return to ssh forwarding",
                                  "4) Manage Configuration and Bash",
                                  "5) Exit"])
コード例 #7
0
def view_drives():
    """
    Views the current drives to the user
    """
    drives = []
    file = module.input_file(MOUNT_FILE)
    for i in range(0, len(file), 3):
        drives.append(str(int(int(i)/3 + 1)) + ") " + file[i])
        drives.append("   " + file[i + 1])
        drives.append("   " + file[i + 2])
    module.print_menu("SSH Drives", drives)
コード例 #8
0
ファイル: ssh_manager.py プロジェクト: zethra/bash_manager
def main():
    """
    This function inputs all the available hosts from a text file and 
    prompts the user to connect to them
    :return:
    """
    file = module.input_file(INPUT_FILE)

    cmp = []
    count = 1

    for line in file:
        cmp.append(Computer(line, count))
        count += 1

    menu = []

    for c in cmp:
        menu.append(str(c.menu_id) + ") " + c.host)
    menu.append("A) Exit")
    menu.append("B) Manager tools")
    menu.append("C) Socks Tunnel")
    menu.append("D) SSH Drive Manager")

    module.print_menu("SSH manager V 1.0", menu)

    i = input("Enter Option:")

    if i == '' or i == 'A' or i == 'a':
        exit_program()
    elif i == 'b' or i == 'B':
        sub_menu()
    elif "c" == str.lower(i):
        socks_ssh_tunnel()
    elif "d" == str.lower(i):
        mount_ssh_drive.main()
    else:
        for c in cmp:
            if int(i) == c.menu_id:
                subprocess.call(["ssh", c.host])
                exit_program()
コード例 #9
0
ファイル: ssh_manager.py プロジェクト: zethra/bash_manager
def copy_ssh_key():
    """
    calls systems ssh-copy-id with host name
    :return: None
    """
    file = module.input_file(INPUT_FILE)
    cmp = []
    count = 1
    for line in file:
        cmp.append(Computer(line, count))
        count += 1

    menu = []
    for c in cmp:
        menu.append(str(c.menu_id) + ") " + c.host)
    menu.append("A) Exit")
    module.print_menu("Copy SSH Key", menu)

    host_id = input("Enter number of host to copy ssh key to:")
    if not (host_id == '-1' or host_id.lower() == 'a'):
        for c in cmp:
            if c.menu_id == int(host_id):
                subprocess.call(["ssh-copy-id", c.host])
コード例 #10
0
def main():
    """
    This function inputs all the available hosts from a text file and
    prompts the user to connect to them
    :return:
    """
    file = module.input_file(INPUT_FILE)

    cmp = []
    count = 1

    for line in file:
        cmp.append(Computer(line, count))
        count += 1
    menu = []

    for c in cmp:
        menu.append(str(c.user_num) + ") " + "".join(c.user))
    menu.append("A) Exit")
    menu.append("B) Manager tools")

    module.print_menu("SSH forwarding manager V 1.0", menu)

    i = input("Enter Option:")

    if i == '' or i == 'A' or i == 'a':
        exit_program()
    elif i == 'B' or i == 'b':
        sub_menu()
    else:
        for c in cmp:
            if int(i) == c.user_num:
                subprocess.call(
                    ["ssh", "-L", c.user.split(":")[2] + ":localhost:"
                     + c.user.split(":")[2], c.user.split(":")[1]])
                exit_program()